用户登录
用户注册

分享至

ios-在视图上挖个洞

  • 作者: 萬千寵愛-范范
  • 来源: 51数据库
  • 2021-07-08

view背景为黑色半透明,右下角挖一个矩形显示底部图层。

		_tapView = [[UIView alloc] initWithFrame:self.view.bounds];
        _tapView.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];
        // 贝塞尔绘制区域
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.view.bounds];
        // 扣出右下角矩形区域
        [path appendPath:[[UIBezierPath bezierPathWithRoundedRect:smallRect cornerRadius:5] bezierPathByReversingPath]];
        
        CAShapeLayer *shapeLayer = [CAShapeLayer layer];
        shapeLayer.path = path.CGPath;
        // 约束layer
        [_tapView.layer setMask:shapeLayer];

二维码扫描,用户指引等功能界面会用到。

软件
前端设计
程序设计
Java相关