iOS引导视图镂空效果
作者:
lym不解释 | 来源:发表于
2020-03-15 18:22 被阅读0次
![](https://img.haomeiwen.com/i2051176/fda6e3accf95ce12.png)
999999999.png
- (void)showViewRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius
{
[[UIApplication sharedApplication].keyWindow addSubview:self];
CGRect frame = [UIScreen mainScreen].bounds;
[self addSubview:self.imageView];
// 第一个路径
UIBezierPath *path = [UIBezierPath bezierPathWithRect:frame];
// 透明path
UIBezierPath *path2 = [[UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius] bezierPathByReversingPath];
[path appendPath:path2];
// 绘制透明区域
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = path.CGPath;
[self.layer setMask:shapeLayer];
self.imageView.centerX = CGRectGetCenter(rect).x - self.imageView.width * 0.5;
self.imageView.y = CGRectGetMaxY(rect) + 20;
}
本文标题:iOS引导视图镂空效果
本文链接:https://www.haomeiwen.com/subject/yeypehtx.html
网友评论