Skip to content

Instantly share code, notes, and snippets.

@qy1010
Created June 13, 2019 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qy1010/d45f2fd7596c013676d4ba6757d4da90 to your computer and use it in GitHub Desktop.
Save qy1010/d45f2fd7596c013676d4ba6757d4da90 to your computer and use it in GitHub Desktop.
设置圆角
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