Question

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?

Was it helpful?

Solution

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

[cell.layer setMasksToBounds:NO];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top