Shadow not showing on cell in iOS

半世苍凉 提交于 2019-12-08 16:25:19

问题


I am using UICollectionView to generate several thumbnails in a Master View.

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?


回答1:


You need to enable the shadow to be created outside of the bounds;

[cell.layer setMasksToBounds:NO];



来源:https://stackoverflow.com/questions/12874684/shadow-not-showing-on-cell-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!