I need to create a shadow for cells inside a UICollectionView . I subclassed the cells and inside the layoutSubviews I added the following code:
-(void)layoutSubviews{ [super layoutSubviews]; self.layer.masksToBounds = NO; self.layer.shadowOpacity = 0.75f; self.layer.shadowRadius = 5.0f; self.layer.shadowOffset = CGSizeZero; self.layer.shadowColor = [UIColor blackColor].CGColor; self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath; }
But the cells are getting taller, and this is the result:

If I remove:
self.layer.masksToBounds = NO;
Cells are displayed correctly (with a distance of 10 pixels between them), but the shadow is not visible. What am I doing wrong? Also, is it correct to add a shadow inside the layoutSubviews method?
ios objective-c uicollectionview uicollectionviewcell
Signo
source share