Skip to content

Instantly share code, notes, and snippets.

@jdriscoll
Created February 28, 2013 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdriscoll/5060773 to your computer and use it in GitHub Desktop.
Save jdriscoll/5060773 to your computer and use it in GitHub Desktop.
Category method to resize a UIImage
- (UIImage *)resize:(CGSize)size quality:(CGInterpolationQuality)interpolationQuality
{
UIGraphicsBeginImageContextWithOptions(size, NO, 1.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetInterpolationQuality(context, interpolationQuality);
[self drawInRect:CGRectMake(0.0, 0.0, size.width, size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment