Adding rounded corner and drop shadow to UICollectionViewCell

前端 未结 15 2640
逝去的感伤
逝去的感伤 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:50

    You can set shadow color, radius and offset in UICollectionViewDataSource method while creating a UICollectionViewCell

    cell.layer.shadowColor = UIColor.gray.cgColor
    cell.layer.shadowOffset = CGSize(width: 0, height: 2.0)
    cell.layer.shadowRadius = 1.0
    cell.layer.shadowOpacity = 0.5
    cell.layer.masksToBounds = false
    

提交回复
热议问题