Rounded UIView using CALayers - only some corners - How?

后端 未结 14 2034
南方客
南方客 2020-11-22 13:53

In my application - there are four buttons named as follows:

  • Top - left
  • Bottom - left
  • Top - right
  • Bottom - right

Abov

14条回答
  •  悲哀的现实
    2020-11-22 14:15

    I have used this code in many places in my code and it works 100% correctly. You can change any corder by changed one property "byRoundingCorners:UIRectCornerBottomLeft"

    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10.0, 10.0)];
    
                    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
                    maskLayer.frame = view.bounds;
                    maskLayer.path = maskPath.CGPath;
                    view.layer.mask = maskLayer;
                    [maskLayer release];
    

提交回复
热议问题