iOS 指定区域透明,镂空

        //整体区域
        UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRect:[UIScreen mainScreen].bounds];
        
        //在整体区域上,镂空透明区域

        CGRect rect = CGRectmake(100,100,100,100);

        //指定区域
        UIBezierPath *clearPath = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:0];

        [bezierPath appendPath: clearPath];
        [bezierPath setUsesEvenOddFillRule:YES];

        //创建layer显示
        self.Layer = [CAShapeLayer layer];

        self.Layer.path = bezierPath.CGPath;

        [self.Layer setFillRule:kCAFillRuleEvenOdd];

//        [self.Layer setFillColor:RGBA(0, 0, 0, 0.6).CGColor];

        self.Layer.opacity = 0.6;

        //添加到View上
        [View.layer addSublayer:self.Layer];

你可能感兴趣的:(iOS 指定区域透明,镂空)