我想为 TableView Cell 内的 UIView 设置具有阴影效果的角半径的不同值,如下所示:
我的代码是:
cell.headerView.round(corners: [.topRight], radius: 35)
extension UIView {
func round(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
self.layoutIfNeeded()
}
}
这适用于 iPhone SE 模拟器,但不适用于 iPhone 6S 模拟器。