简体   繁体   English

阴影未显示在iOS中的单元格上

[英]Shadow not showing on cell in iOS

I am using UICollectionView to generate several thumbnails in a Master View. 我正在使用UICollectionView在主视图中生成多个缩略图。

This works fine and I am able to place a border around the cells as well as apply border (corner) radius. 这工作正常,我能够在单元格周围放置边框以及应用边框(角落)半径。

The only thing that does not seem to stick is the shadow for each cell. 唯一似乎没有坚持的是每个细胞的阴影。

Here is my code 这是我的代码

....

[cell.layer setBorderColor:[UIColor colorWithRed:213.0/255.0f green:210.0/255.0f blue:199.0/255.0f alpha:1.0f].CGColor];
[cell.layer setBorderWidth:1.0f];
[cell.layer setCornerRadius:7.5f];
[cell.layer setShadowOffset:CGSizeMake(0, 1)];
[cell.layer setShadowColor:[[UIColor darkGrayColor] CGColor]];
[cell.layer setShadowRadius:8.0];
[cell.layer setShadowOpacity:0.8];

return cell;

Do you know what I'm doing wrong and what I can do for the shadow to show? 你知道我做错了什么,我能做些什么让阴影显示出来?

You need to enable the shadow to be created outside of the bounds; 您需要启用在边界之外创建的阴影;

[cell.layer setMasksToBounds:NO]; [cell.layer setMasksToBounds:NO];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM