-
-
Save cbueno/3645147 to your computer and use it in GitHub Desktop.
UIImage+Resize.m Fix for Rotation / Orientation on iOS 5
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
- (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality { | |
BOOL drawTransposed; | |
CGAffineTransform transform = CGAffineTransformIdentity; | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) { | |
// Apprently in iOS 5 the image is already correctly rotated, so we don't need to rotate it manually | |
drawTransposed = NO; | |
} else { | |
switch (self.imageOrientation) { | |
case UIImageOrientationLeft: | |
case UIImageOrientationLeftMirrored: | |
case UIImageOrientationRight: | |
case UIImageOrientationRightMirrored: | |
drawTransposed = YES; | |
break; | |
default: | |
drawTransposed = NO; | |
} | |
transform = [self transformForOrientation:newSize]; | |
} | |
return [self resizedImage:newSize | |
transform:transform | |
drawTransposed:drawTransposed | |
interpolationQuality:quality]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment