0

I want to develop shadow to my collectionViewItem like this: enter image description here

How could I achieve this? I am using a UICollectionView.

  • Hi @matt that duplicate answer you are suggesting didn't work for me. –  May 24 '18 at 18:53
  • 1
    Hi @Tanveer! The point is simply that your question is very broad and that the entire matter of how to add a rounded border and shadow to a collection view cell has been dealt with here, in depth, many times before, so that searching would turn up all the info you need. Thus, the new repetition of the question really doesn't need to happen. – matt May 24 '18 at 19:33

1 Answers1

1
  • add a view to your cell with left, right, top, and bottom constraint of 5 (or whatever).

  • add put all your cell content in that view

  • create an outlet for the view

  • style:

    yourView.layer.borderColor = UIColor(red:0, green:0, blue:0, alpha:0.5).cgColor
    yourView.layer.shadowOffset = CGSize(width: 0, height: 2)
    yourView.layer.shadowColor = UIColor(red:0, green:0, blue:0, alpha:0.5).cgColor
    yourView.layer.shadowOpacity = 0.5
    yourView.layer.shadowRadius = 3
    
  • and if you want rounded corners:

    yourView.layer.cornerRadius = 8
    
shayegh
  • 302
  • 1
  • 9