美文网首页
iOS 做操作引导 中部镂空效果

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

作者: 隐身人 | 来源:发表于2020-10-15 11:50 被阅读0次

镂空效果实现


    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;

效果

相关文章

网友评论

      本文标题:iOS 做操作引导 中部镂空效果

      本文链接:https://www.haomeiwen.com/subject/dwpnpktx.html