美文网首页
iOS 指定区域透明,镂空

iOS 指定区域透明,镂空

作者: 原来可以这样 | 来源:发表于2020-08-25 17:16 被阅读0次
        //整体区域
        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 指定区域透明,镂空

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