Created
November 20, 2013 01:08
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIImage (ResizeImage) | |
+ (UIImage *)convertImage:(UIImage *)image toSize:(CGSize)size; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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