Search code examples
iosswiftuitableviewuicollectionviewuikit

How can I make my UICollectionViewCell Shadow bleed through to my main View?


I currently have a UICollectionView (Horizontal) inside a UITableViewCell. I want to add a shadow to the collection view cell, however the shadow gets cut off because of the tableview cell height. Is there any way to make the shadow bleed through?

(It might be hard to tell from this image, but its getting cut off on the top and bottom)

I have a "background" that clips to the boundaries of the CVCell,

background.backgroundColor = .white
background.layer.cornerRadius = 8
background.layer.shadowColor = UIColor.black.cgColor
background.layer.shadowRadius = 7
background.layer.shadowOpacity = 0.3
background.layer.shadowOffset = CGSize(width: 0, height: 3)
background.layer.masksToBounds = true
background.clipsToBounds = false

And in my UITableViewCell (Not the cell with the background) I set

cell.layer.masksToBounds = false
cell.clipsToBounds = true

Solution

  • Please check the top and button constraint settings for the collectionView cell.