IOS develop and set View. A corner is fillet.

UIBezierPath and CAShapeLayer need to be implemented.

 

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;

 

 

Select the top and bottom by enumerating type UIRectCorner.

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
            UIRectCornerTopLeft = 1 << 0,
            UIRectCornerTopRight = 1 << 1,
            UIRectCornerBottomLeft = 1 << 2,
            UIRectCornerBottomRight = 1 << 3,
            UIRectCornerAllCorners = ~0UL
            
        };

 

UILabelSetting corners may cause problems.

If Uilabel sets a rounded corner, a thin line may appear on a high-resolution phone, because the width of the label is not an integer, just take an integer.

 

 

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer;

Author: thin Liang Jian
Link: https://www.jianshu.com/p/867124573ab0
Source: brief book
Copyright of the handbook is vested in the author. Any reprint of the handbook should be authorized by the author and the source should be indicated.

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer;

Author: thin Liang Jian
Link: https://www.jianshu.com/p/867124573ab0
Source: brief book
Copyright of the handbook is vested in the author. Any reprint of the handbook should be authorized by the author and the source should be indicated.

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer;

Author: thin Liang Jian
Link: https://www.jianshu.com/p/867124573ab0
Source: brief book
Copyright of the handbook is vested in the author. Any reprint of the handbook should be authorized by the author and the source should be indicated.

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer;

Author: thin Liang Jian
Link: https://www.jianshu.com/p/867124573ab0
Source: brief book
Copyright of the handbook is vested in the author. Any reprint of the handbook should be authorized by the author and the source should be indicated.

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer;

Author: thin Liang Jian
Link: https://www.jianshu.com/p/867124573ab0
Source: brief book
Copyright of the handbook is vested in the author. Any reprint of the handbook should be authorized by the author and the source should be indicated.

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view.bounds; maskLayer.path = maskPath.CGPath; view.layer.mask = maskLayer;

Author: thin Liang Jian
Link: https://www.jianshu.com/p/867124573ab0
Source: brief book
Copyright of the handbook is vested in the author. Any reprint of the handbook should be authorized by the author and the source should be indicated.

Leave a Reply

Your email address will not be published. Required fields are marked *