UIView指定角为圆角

代码:

UIView *one = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)];
one.backgroundColor = [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000];
[self.view addSubview:one];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:one.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
maskLayer.frame = one.bounds;
maskLayer.path = maskPath.CGPath;
one.layer.mask = maskLayer;

效果图:

UIView指定角为圆角_第1张图片
2222.png

你可能感兴趣的:(UIView指定角为圆角)