美文网首页
UIView的部分角切圆角

UIView的部分角切圆角

作者: InitWithYou | 来源:发表于2016-09-22 11:01 被阅读463次
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 100, 80, 80)];
view2.backgroundColor = [UIColor redColor];
[self.view addSubview:view2];
    
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds          
 byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(40, 40)];
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

相关文章

网友评论

      本文标题:UIView的部分角切圆角

      本文链接:https://www.haomeiwen.com/subject/pqrzettx.html