iOS 做操作引导 中部镂空效果

镂空效果实现


    UIImageView *guide_bg = [[UIImageView alloc]init];
    guide_bg.frame = CGRectMake(0, 0, MooVW(bg), MooVH(bg));
    guide_bg.image = [UIImage imageNamed:@"guide_bg"];//一张半透明黑灰背景图片
    [bg addSubview:guide_bg];
    
    UIBezierPath *bpath = [UIBezierPath bezierPathWithRoundedRect:guide_bg.frame cornerRadius:0];
    
    // - bezierPathByReversingPath ,反方向绘制path

    [bpath appendPath:[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(guide_bg.frame.size.width/2-50, guide_bg.frame.size.height/2-50, 100, 100) cornerRadius:2] bezierPathByReversingPath]];
    
    [bpath appendPath:[UIBezierPath bezierPathWithArcCenter:CGPointMake(guide_bg.frame.size.width/2-150, guide_bg.frame.size.height/2-50) radius:30 startAngle:0 endAngle:2*M_PI clockwise:NO]];
    
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    shapeLayer.path = bpath.CGPath;
    guide_bg.layer.mask = shapeLayer;

效果
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。