标签:ring star number clear null extc object tar cal
http://blog.csdn.net/jeffasd/article/details/50805312
https://jackliu17.github.io/2016/05/03/%E4%BD%BF%E7%94%A8maskView%E8%AE%BE%E8%AE%A1%E5%8A%A8%E7%94%BB%E5%8F%8A%E9%81%AE%E7%9B%96/
http://www.jianshu.com/p/191e2aae90b0
当用户第一次使用app的时候, 在app的开始页或者主要的界面,就会显示用户引导,引导用户怎么使用这个app。就类似下面这种界面(随便找张QQ的截图做为app的界面)
总的来说,还是比较简单的。下面是我遇到的过程中想到的几种方法
1、用CALayer的mask层来实现
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.view.bounds];
[path addArcWithCenter:CGPointMake(CGRectGetWidth(self.view.bounds)/2, CGRectGetHeight(self.view.bounds)/2) radius:50 startAngle:0 endAngle:M_PI *2 clockwise:YES];
path.usesEvenOddFillRule = YES;
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = path.CGPath;
shapeLayer.fillColor= [UIColor blackColor].CGColor; //其他颜色都可以,只要不是透明的
shapeLayer.fillRule=kCAFillRuleEvenOdd;
UIView *translucentView = [UIView new];
translucentView.frame = self.imaegView.bounds;
translucentView.backgroundColor = [UIColor blackColor];
translucentView.alpha = 0.5;
translucentView.layer.mask = shapeLayer;
[self.view addSubview:translucentView];
//把shapeLayer的透明度改为0.5,直接添加layer也一样
// shapeLayer.opacity = 0.5
//[self.imageView.layer addSublayer:shapeLayer];
2、使用透明图片作为UIView来实现
UIView *translucentView = [UIView new];
translucentView.frame = self.imaegView.bounds;
translucentView.backgroundColor = [UIColor blackColor];
translucentView.alpha = 0.5;
UIImageView *maskView = [UIImageView new];
maskView.frame = self.imaegView.bounds;
maskView.image = [UIImage imageNamed:@"translucent"];
maskView.contentMode = UIViewContentModeScaleToFill;
// maskView.
translucentView.maskView = maskView;
[self.imaegView addSubview:translucentView];
3、使用drawRect:(CGRect)rect实现(参考别人的)
- (void)drawRect:(CGRect)rect{ //创建路径并获取句柄
CGMutablePathRef path = CGPathCreateMutable(); //指定矩形
CGRect rectangle = self.bounds; //将矩形添加到路径中
CGPathAddRect(path,NULL, rectangle); //获取上下文
CGContextRef currentContext = UIGraphicsGetCurrentContext(); //将路径添加到上下文
CGContextAddPath(currentContext, path); //设置矩形填充色 CGContextSetFillColorWithColor(currentContext,
[UIColor colorWithWhite:0.0f alpha:0.8f].CGColor);
CGContextFillRect(currentContext, rectangle);
CGContextClearRect(currentContext, CGRectMake(50.f, 50.f, 220.f, 220.f));//绘制
CGContextDrawPath(currentContext, kCGPathFillStroke);
CGPathRelease(path);
}
uiview maskview使用:中间透明的UIView实现的几种方法
标签:ring star number clear null extc object tar cal
原文地址:http://www.cnblogs.com/nbhhcty66/p/7267668.html