Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shadow not showing on cell in iOS

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?

like image 682
pepe Avatar asked Oct 13 '12 15:10

pepe


1 Answers

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

[cell.layer setMasksToBounds:NO];

like image 161
Daniel Nordh Avatar answered Nov 01 '22 09:11

Daniel Nordh