Skip to content

Instantly share code, notes, and snippets.

@ArtSabintsev
Created November 20, 2013 01:08
Show Gist options
  • Save ArtSabintsev/7555765 to your computer and use it in GitHub Desktop.
Save ArtSabintsev/7555765 to your computer and use it in GitHub Desktop.
This UIImage category adds one class method that enables you to resize an image, in case you have an asset that is too large.
#import <UIKit/UIKit.h>
@interface UIImage (ResizeImage)
+ (UIImage *)convertImage:(UIImage *)image toSize:(CGSize)size;
@end
#import "UIImage+ResizeImage.h"
@implementation UIImage (ResizeImage)
+ (UIImage *)convertImage:(UIImage *)image toSize:(CGSize)size
{
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(0.0f, 0.0f, size.width, size.height)];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resizedImage;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment