Created
December 18, 2015 12:35
-
-
Save bigeyex/e5a2ba7a27930415ac86 to your computer and use it in GitHub Desktop.
UIImage+Resize.h - resize UIImages
This file contains 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 <Foundation/Foundation.h> | |
@interface UIImage (Resize) | |
- (UIImage *)resizeTo:(CGSize)newSize; | |
@end |
This file contains 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+Resize.h" | |
@implementation UIImage (Resize) | |
- (UIImage *)resizeTo:(CGSize)newSize | |
{ | |
CGFloat scale = [[UIScreen mainScreen]scale]; | |
/*You can remove the below comment if you dont want to scale the image in retina device .Dont forget to comment UIGraphicsBeginImageContextWithOptions*/ | |
//UIGraphicsBeginImageContext(newSize); | |
UIGraphicsBeginImageContextWithOptions(newSize, NO, scale); | |
[self drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; | |
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return newImage; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment