[英]How to add a shadow to the inside bottom edge of a collection view cell? swift 3
I'd like to create a collectionViewCell, I currently have a UIImageView taking up the entire contentView of the cell but would like to add a shadow to the bottom of the image (starting at the bottom edge going towards the middle of the cell). 我想创建一个collectionViewCell,目前我有一个UIImageView占用了单元格的整个contentView,但想在图像的底部添加阴影(从底部边缘开始朝向单元格的中间)。 How would I go about doing this in swift 3?
我将如何迅速进行3?
Thanks 谢谢
Try this: 尝试这个:
yourCollectionViewCell.layer.masksToBounds = false
yourCollectionViewCell.layer.borderColor = UIColor.white.cgColor
yourCollectionViewCell.layer.borderWidth = 7.0
yourCollectionViewCell.layer.contentsScale = UIScreen.main.scale
yourCollectionViewCell.layer.shadowOpacity = 0.75
yourCollectionViewCell.layer.shadowRadius = 5.0
yourCollectionViewCell.layer.shadowOffset = CGSize.zero
yourCollectionViewCell.layer.shadowPath = UIBezierPath.init(rect: yourCollectionViewCell.bounds).cgPath
cell.layer.shouldRasterize = true
This is my example. 这是我的例子。 you try customize as you like.
您可以尝试根据需要自定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.