简体   繁体   English

如何在集合视图单元的内部底部边缘添加阴影? 迅捷3

[英]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.

相关问题 如何在iOS的TableView中的单元格内部的视图中添加阴影? - How to add shadow to a view inside cell in tableview in ios? 如何在表格视图单元格的顶部和底部放置阴影? - How can i drop shadow to top and bottom of view which is inside the table view cell? 集合视图中单元格的外部阴影未显示 swift ios - Outside shadow of a cell in a collection view not showing up swift ios 如何为集合视图单元格内的视图添加手势? - How to add gesture for a view inside a collection view cell? 如何使用swift将单元格添加到动态集合视图中 - How to add cell to dynamic collection view using swift 如何在Swift中为视图集合中的每个单元格添加弹出窗口 - How to add popovers for every cell in view collection in Swift 如何在Collection视图-Swift中为每个单元格添加edgeInsets - How to add edgeInsets for each cell in Collection view -Swift 如何在Swift中向Collection View Cell添加删除按钮? - How to add a delete button to Collection View Cell in Swift? 如何在集合视图单元格的某一部分中添加多个数组,该集合视图位于tableView单元格内? - How to add multi arrays in one section of Collection View Cell which that collection view inside tableView cell? 将单元格添加到集合视图。 迅速 - Add cell to collection view. Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM