Created
January 13, 2015 15:18
-
-
Save bogren/39f3417fde5db4a6fb9d to your computer and use it in GitHub Desktop.
Crop to keep bottom part of UIImage
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
- (UIImage *)cropImage:(UIImageView *)image { | |
UIGraphicsBeginImageContext(CGSizeMake(320, 64)); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextTranslateCTM(context, 0, -image.frame.size.height + 64); | |
[image.layer renderInContext:context]; | |
UIImage *subImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return subImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment