Created
June 13, 2019 08:38
-
-
Save qy1010/d45f2fd7596c013676d4ba6757d4da90 to your computer and use it in GitHub Desktop.
设置圆角
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGRect rect = self.bounds; | |
// Create the path | |
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect | |
byRoundingCorners:corners | |
cornerRadii:CGSizeMake(radius, radius)]; | |
// Create the shape layer and set its path | |
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = rect; | |
maskLayer.path = maskPath.CGPath; | |
// Set the newly created shape layer as the mask for the view's layer | |
self.layer.mask = maskLayer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment