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
| #pragma mark - UIImage Scaler Category | |
| @interface UIImage (scale) | |
| -(UIImage*)scaleToSize:(CGSize)size; | |
| @end | |
| @implementation UIImage (scale) | |
| -(UIImage*)scaleToSize:(CGSize)size{ | |
| UIGraphicsBeginImageContext(size); // Create a bitmap graphics context (also sets it as the current context) | |
| [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; // Draw the scaled image in the current context | |
| UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); // Create a new image from current context |