Note that there are some explanatory texts on larger screens.

plurals
  1. POUICollectionViewCell with rounded corners AND drop shadow not working
    primarykey
    data
    text
    <p>I want my UICollectionViewCells to have rounded corners and drop shadows but I have run into a problem where it seems I can only have one or the other, but not both.</p> <p>To just round the corners I use this code in the initialization of the cell:</p> <pre><code>CALayer *layer = [self layer]; [layer setCornerRadius:4]; [layer setRasterizationScale:[[UIScreen mainScreen] scale]]; [layer setShouldRasterize:YES]; </code></pre> <p>To just add a drop shadow I use this code in the initialization of the cell:</p> <pre><code>CALayer *layer = [self layer]; [layer setMasksToBounds:NO]; [layer setRasterizationScale:[[UIScreen mainScreen] scale]]; [layer setShouldRasterize:YES]; [layer setShadowColor:[[UIColor blackColor] CGColor]]; [layer setShadowOffset:CGSizeMake(0.0f,0.5f)]; [layer setShadowRadius:8.0f]; [layer setShadowOpacity:0.2f]; [layer setShadowPath:[[UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:layer.cornerRadius] CGPath]]; </code></pre> <p>To try and have rounded corners and a drop shadow I use this code in the initialization of the cell:</p> <pre><code>CALayer *layer = [self layer]; [layer setMasksToBounds:NO]; [layer setCornerRadius:4]; [layer setRasterizationScale:[[UIScreen mainScreen] scale]]; [layer setShouldRasterize:YES]; [layer setShadowColor:[[UIColor blackColor] CGColor]]; [layer setShadowOffset:CGSizeMake(0.0f,0.5f)]; [layer setShadowRadius:8.0f]; [layer setShadowOpacity:0.2f]; [layer setShadowPath:[[UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:layer.cornerRadius] CGPath]]; </code></pre> <p>but this results in the drop shadow only.</p> <p>Is this a bug or am I doing something wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload