設定控制元件的某個圓角 (Swift4)
阿新 • • 發佈:2019-02-08
給控制元件設定圓角
//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 }