二维码扫码的时候,背景是黑色的,中间有个中空的部分。
1.画1条外边框矩形
2.再画一条内边框矩形,设置成反向绘制。
3.两条曲线拼接,设置背景的layey.mask即可。
UIView *bgView = [[UIView alloc] initWithFrame:self.view.bounds];
bgView.backgroundColor = [UIColor blackColor];
bgView.alpha = 0.5;
[self.view addSubview:bgView];
UIBezierPath *path1 = [UIBezierPath bezierPathWithRect:self.view.bounds];
UIBezierPath *path2 = [[UIBezierPath bezierPathWithRoundedRect:CGRectMake(50, 100, self.view.frame.size.width-100, 200) cornerRadius:10]
bezierPathByReversingPath];
[path1 appendPath:path2];
CAShapeLayer *maskL = [[CAShapeLayer alloc] init];
maskL.path = path1.CGPath;
bgView.layer.mask = maskL;