Adding rounded corner and drop shadow to UICollectionViewCell

前端 未结 15 2635
逝去的感伤
逝去的感伤 2020-12-12 09:50

So I already went through various posts on adding 2nd view for adding shadow, but I still cannot get it to work if I want to add it in UICollectionViewCell. I s

15条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 10:35

    You simply need to (a) set cornerRadius and (b) set shadowPath to be a rounded rect with the same radius as cornerRadius:

    self.layer.cornerRadius = 10;
    self.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.layer.cornerRadius] CGPath];
    

提交回复
热议问题