Skip to content

Instantly share code, notes, and snippets.

@MaximAlien
Created February 12, 2016 11:24
Show Gist options
  • Save MaximAlien/15f7ae5979e545a9b904 to your computer and use it in GitHub Desktop.
Save MaximAlien/15f7ae5979e545a9b904 to your computer and use it in GitHub Desktop.
[iOS] Create new image with different size
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)size
{
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
[image drawInRect:CGRectMake(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