设置控件的某个圆角 (Swift4)

给控件设置圆角

 //MARK: 设置某个圆角
    func configSideRadius(iv: UIView) {
        //MARK: 设置阴影,圆角,一定要根据 屏幕的尺寸/self的bounds 设定;不能使用自身尺寸
        let bounds = CGRect.init(x: 0, y: 0, width: self.bounds.width - 30, height: (self.bounds.width - 30) * 29 / 65)
        let maskPath = UIBezierPath.init(roundedRect: bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 5, height: 5))
        let maskLayer = CAShapeLayer.init()
        maskLayer.path = maskPath.cgPath
        iv.layer.mask = maskLayer
    }

 

你可能感兴趣的:(圆角)