iOS开发之指定UIView的某几个角为圆角

UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];

view2.backgroundColor = [UIColor redColor];

[self.view addSubview:view2];

    

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

maskLayer.frame = view2.bounds;

maskLayer.path = maskPath.CGPath;

view2.layer.mask = maskLayer;

其中,

byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight

指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有:

* UIRectCornerTopLeft

* UIRectCornerTopRight

* UIRectCornerBottomLeft

* UIRectCornerBottomRight

* UIRectCornerAllCorners


参考链接http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how

你可能感兴趣的:(ios,view,圆角)