Created
February 19, 2015 20:57
-
-
Save loganwright/e13d367f06174fd47621 to your computer and use it in GitHub Desktop.
UIImage+Resize
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 (Resize) | |
- (UIImage *)scaleToSize:(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+Resize.h" | |
@implementation UIImage (Resize) | |
- (UIImage *)scaleToSize:(CGSize)size | |
{ | |
UIGraphicsBeginImageContext(size); | |
[self drawInRect:CGRectMake(0, 0, size.width, size.height)]; | |
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
// Return our new scaled image | |
return scaledImage; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment