iOS在蒙版上扣出形状

2019-09-29  本文已影响0人  _秃头少女_
效果图 2019-09-10 下午5.00.53.png
class CustomerView: UIView {
    
//    var maskView = UIView.init()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.black.withAlphaComponent(0.6)

        let fullPath = UIBezierPath.init(rect: UIScreen.main.bounds)
        let layer = CAShapeLayer.init()
        
        let bpath = UIBezierPath.init(roundedRect: CGRect(x: 100, y: 100, width: 100, height: 100), cornerRadius: 5).reversing()
        let bpath1 =  UIBezierPath.init(roundedRect: CGRect(x: 100, y: 200, width: 100, height: 100), cornerRadius: 50).reversing()
        let arcPath = UIBezierPath.init(arcCenter: CGPoint(x: 150, y: 320), radius: 50, startAngle: 0, endAngle: CGFloat(M_PI*3/4), clockwise: true).reversing()
        
        fullPath.append(bpath)
        
        fullPath.append(bpath1)
        fullPath.append(arcPath)

        layer.path = fullPath.cgPath
        
        self.layer.mask = layer
    }
上一篇 下一篇

猜你喜欢

热点阅读