iOS UIView将右上角舍入仅适用于左上角

时间:2019-03-22 10:29:46

标签: ios swift uiview

我想修整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)

结果

enter image description here

0 个答案:

没有答案