Created
November 4, 2013 16:02
-
-
Save joanromano/7304803 to your computer and use it in GitHub Desktop.
Setting a UIImageView's image without using cornerRadius and masksToBounds
This file contains hidden or 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
- (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