Skip to content

Instantly share code, notes, and snippets.

@saiday
Created August 9, 2016 06:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saiday/edf88d44932accb6ccd6f4ae659ec3d8 to your computer and use it in GitHub Desktop.
Save saiday/edf88d44932accb6ccd6f4ae659ec3d8 to your computer and use it in GitHub Desktop.
Effective corner radius
- (UIImage *)cutCircleImage {
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0);
CGContextRef ctr = UIGraphicsGetCurrentContext();
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
CGContextAddEllipseInRect(ctr, rect);
CGContextClip(ctr);
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment