// 可以扫描的区域
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
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 大部分schemes 都必须在微信内部才能打开,除了 weixin:// wechat:// etc 直接打开微信...