iOS 让UIView的左上角和右上角为圆角

/**平台保障背景view*/
-(UIView *)platFormBGV{
    if (!_platFormBGV) {
        _platFormBGV = [[UIView alloc] init];
        _platFormBGV.backgroundColor = [UIColor whiteColor];
        _platFormBGV.frame = CGRectMake(0, self.view.frame.size.height, APP_SCREEN_WIDTH, 220);
    
        // 左上和右上为圆角
        UIBezierPath *cornerRadiusPath = [UIBezierPath bezierPathWithRoundedRect:_platFormBGV.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)];
        CAShapeLayer *cornerRadiusLayer = [ [CAShapeLayer alloc ]  init];
        cornerRadiusLayer.frame = _platFormBGV.bounds;
        cornerRadiusLayer.path = cornerRadiusPath.CGPath;
        _platFormBGV.layer.mask = cornerRadiusLayer;
     }
          return _platFormBGV;
}

白色背景效果如下

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

推荐阅读更多精彩内容