我想修整UIView的上角。模拟器iOS版本12.0
我的扩展名
extension UIView
{
func round(corners: UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}
}
我如何使用
test.round(corners: [.topRight, .topLeft], radius: 20)
结果