美文网首页
iOS在蒙版上扣出形状

iOS在蒙版上扣出形状

作者: _秃头少女_ | 来源:发表于2019-09-29 11:25 被阅读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
        }
    

    相关文章

      网友评论

          本文标题:iOS在蒙版上扣出形状

          本文链接:https://www.haomeiwen.com/subject/jedbyctx.html