Skip to content

Instantly share code, notes, and snippets.

@mbelsky
Last active April 4, 2016 07:35
Show Gist options
  • Save mbelsky/275e700dc6ef56c9bc81388016872c71 to your computer and use it in GitHub Desktop.
Save mbelsky/275e700dc6ef56c9bc81388016872c71 to your computer and use it in GitHub Desktop.
Redraw an image for new size
UIImage *image = [[UIImage alloc] initWith: something];
if (image.size.width != kAppIconSize || image.size.height != kAppIconSize) {
CGSize itemSize = CGSizeMake(kAppIconSize, kAppIconSize);
UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0.0f);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[image drawInRect:imageRect];
self.appRecord.appIcon = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment