gpt4 book ai didi

ios - 如何向 Collection View 单元格的内底边缘添加阴影? swift 3

转载 作者:行者123 更新时间:2023-11-30 12:17:03 25 4
gpt4 key购买 nike

我想创建一个collectionViewCell,我目前有一个UIImageView占据了单元格的整个contentView,但想在图像的底部添加阴影(从底部边缘开始朝向图像的中间)细胞)。我将如何在 swift 3 中做到这一点?

谢谢

最佳答案

试试这个:

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

这是我的例子。您尝试根据自己的喜好进行定制。

关于ios - 如何向 Collection View 单元格的内底边缘添加阴影? swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45292771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com