Permalink
Browse files

Fixing issue with iOS < 4.0

  • Loading branch information...
1 parent 3c6fe72 commit 23c0d9ae8de4899c308b027f63461e4710ed66e1 @coryalder committed Nov 8, 2011
Showing with 13 additions and 2 deletions.
  1. +13 −2 UIImage+Resize.m
View
15 UIImage+Resize.m
@@ -21,7 +21,12 @@ @implementation UIImage (Resize)
// This method ignores the image's imageOrientation setting.
- (UIImage *)croppedImage:(CGRect)bounds {
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds);
- UIImage *croppedImage = [UIImage imageWithCGImage:imageRef scale:([self respondsToSelector:@selector(scale)] ? self.scale : 1.0) orientation:self.imageOrientation];
+ UIImage *croppedImage;
+ if ([self respondsToSelector:@selector(scale)] && [UIImage respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) {
+ croppedImage = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation];
+ } else {
+ croppedImage = [UIImage imageWithCGImage:imageRef];
+ }
CGImageRelease(imageRef);
return croppedImage;
}
@@ -133,7 +138,13 @@ - (UIImage *)resizedImage:(CGSize)newSize
// Get the resized image from the context and a UIImage
CGImageRef newImageRef = CGBitmapContextCreateImage(bitmap);
- UIImage *newImage = [UIImage imageWithCGImage:newImageRef scale:([self respondsToSelector:@selector(scale)] ? self.scale : 1.0) orientation:self.imageOrientation];
+ UIImage *newImage;
+ if ([self respondsToSelector:@selector(scale)] && [UIImage respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) {
+ newImage = [UIImage imageWithCGImage:newImageRef scale:self.scale orientation:self.imageOrientation];
+ } else {
+ newImage = [UIImage imageWithCGImage:newImageRef];
+ }
+
// Clean up
CGContextRelease(bitmap);

0 comments on commit 23c0d9a

Please sign in to comment.