美文网首页
扫一扫黑色背景掏洞demo

扫一扫黑色背景掏洞demo

作者: 走道牙的人 | 来源:发表于2016-09-02 11:50 被阅读16次
    // 可以扫描的区域
    CGRect rect = CGRectMake((DBScreenW - 188) / 2.0, (DBScreenH - 188) / 2.0, 188, 188);
    
    UIView *maskView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    maskView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    [self.scanView addSubview:maskView];
    
    // 配置不能扫描区域的遮罩
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:[UIScreen mainScreen].bounds];
    [path appendPath:[[UIBezierPath bezierPathWithRect:rect] bezierPathByReversingPath]];
    
    CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
    shapeLayer.path = path.CGPath;
    maskView.layer.mask = shapeLayer;
    

    相关文章

      网友评论

          本文标题:扫一扫黑色背景掏洞demo

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