Skip to content

Instantly share code, notes, and snippets.

@joanromano
Created November 4, 2013 16:02
Show Gist options
  • Save joanromano/7304803 to your computer and use it in GitHub Desktop.
Save joanromano/7304803 to your computer and use it in GitHub Desktop.
Setting a UIImageView's image without using cornerRadius and masksToBounds
- (void)setImage:(UIImage *)image withCornerRadius:(CGFloat)cornerRadius
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 1.0);
[[UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornerRadius] addClip];
[image drawInRect:self.bounds];
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment