Skip to content

Instantly share code, notes, and snippets.

@carlosmcevilly
Last active December 16, 2015 03:59
Show Gist options
  • Save carlosmcevilly/5374240 to your computer and use it in GitHub Desktop.
Save carlosmcevilly/5374240 to your computer and use it in GitHub Desktop.
Scale an image (Objective-C)
- (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, YES, 0.0);
CGRect imageRect = {{0.0, 0.0}, newSize};
[image drawInRect:imageRect];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment