我正在尝试重新创建脸谱网设置页面
这就是脸谱网设置页面的样子:
https://gfycat.com/SizzlingSorrowfulGrayfox
我已经启动了一个新项目,只使用1个TabLVIEW,使用样式分组、节和头。
我想绕过TabVIEW的每个部分。我必须将标题的左上角和右上角(节的顶部)以及最后一个单元格的左下角和右下角(节的底部)围起来。
我已经完成了上面的部分,使用下面的代码
HeaderTableViewCell
:
let rectShape = CAShapeLayer()
rectShape.bounds = self.frame
rectShape.position = self.center
rectShape.path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: [.topLeft , .topRight], cornerRadii: CGSize(width: 10, height: 10)).cgPath
self.layer.mask = rectShape
然而,当我为最后一个细胞做同样的事情时,奇怪的事情发生了。
https://gfycat.com/UnselfishCommonFlee
当第一次加载页面时,角点是正确的圆角,但是当我向下和向上滚动时,第二个最后的单元格是圆角。
这是我在最后一个牢房的密码
cellForRowAt
:
if indexPath.row + 1 == childArray?.count { //last cell, set corner radius
print("is last cell")
let rectShape = CAShapeLayer()
rectShape.bounds = rowDataCell.frame
rectShape.position = rowDataCell.center
rectShape.path = UIBezierPath(roundedRect: rowDataCell.bounds, byRoundingCorners: [.bottomLeft , .bottomRight], cornerRadii: CGSize(width: 10, height: 10)).cgPath
rowDataCell.layer.mask = rectShape
}else{
rowDataCell.layer.cornerRadius = 0
}
有什么帮助吗?