I am trying to add shadow to my custom UICollectionViewCell
, This is the code I am using in my custom collection view cell class:
self.layer.shadowOffset = CGSizeMake(1, 0);
self.layer.shadowColor = [[UIColor blackColor] CGColor];
self.layer.shadowRadius = 5;
self.layer.shadowOpacity = .25;
This is giving shadow to the components of the collection view cell.
One alternative approach you can try, take a UIView in UITableViewCell . Set background color of UITableViewCell to clear color. Now, you can make round corners and add shadow on UIVIew . This will appear as if cell width is reduced and user can scroll along the edges of the tableView.
Rounded Corners on a UICollectionViewCell To apply rounded corners, set a cornerRadius on both the layer and contentView. layer properties. On the contentView. layer , set masksToBounds to true so the contentView contents are clipped to the rounded corners.
An object that manages an ordered collection of data items and presents them using customizable layouts.
Don't forget to add these 2 lines
self.clipsToBounds = false
self.layer.masksToBounds = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With