【发布时间】:2017-10-24 12:29:13
【问题描述】:
【问题讨论】:
-
您在互联网上有很多解决方案。尝试其中任何一个,如果您遇到任何错误,我们会在这里为您提供帮助。
-
你可以为你的collectionview设置清晰的颜色并将圆角半径设置为collectionviewcell..
标签: ios swift swift3 uicollectionview rounded-corners
【问题讨论】:
标签: ios swift swift3 uicollectionview rounded-corners
extension UICollectionView {
func roundCorners(_ corners:UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}}
collectioniew.roundCorners([.topLeft,.topRight], radius: 5)
【讨论】:
解决方案非常简单。 我刚刚删除了 collectionViewLayout 顶部的插图,并向 HeaderView 添加了一个新视图。 之后,我将圆角半径应用于添加的视图,它工作了:)
【讨论】: