UIView设置部分圆角---iOS开发UI篇

时间:2022-06-14 23:13:52
    UIView *view = [UIView new];
    view.frame = CGRectMake(100, 100, 300, 100);
    [self.view addSubview:view];
    view.backgroundColor = [UIColor orangeColor];
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(15, 15)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;

  效果图如下:

UIView设置部分圆角---iOS开发UI篇