iOS sets the control fillet with selectable fillet direction
- 2021-07-18 09:09:07
- OfStack
Preface
This article mainly introduces how to use iOS to set the control fillet that can choose the direction of fillet. Needless to say, the following is the example code of realization. Let's have a look.
Sample code
1. Set fillet by setting cornerRadius of control layer
self.view.layer.cornerRadius =10.f;// If the fillet angle is set to a semicircle, the value is the height of the control 1 Half
self.view.layer.masksToBounds = YES;// Delete redundant locations
2. Set fillet by Bezier curve
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:btn.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(10, 10)];
//rect Object for the control frame corners Is the position of the rounded corner cornerRadii Is the size of the fillet
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame =frame;
maskLayer.path = maskPath.CGPath;
btn.layer.mask = maskLayer;
Summarize
The above is the whole content of this article. I hope the content of this article can be helpful to all iOS developers. If you have any questions, you can leave a message for communication.