Created
November 21, 2011 00:23
-
-
Save agassiyzh/1381253 to your computer and use it in GitHub Desktop.
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
@implementation UIImage (TPAdditions) | |
-(id)initWithContentsOfResolutionIndependentFile:(NSString*)path { | |
if([[[UIDevice currentDevice] systemVersion] intValue] >=4&&[[UIScreen mainScreen] scale]==2.0){ | |
NSString*path2x =[[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@@2x.%@", [[path lastPathComponent] stringByDeletingPathExtension], [path pathExtension]]]; | |
if([[NSFileManager defaultManager] fileExistsAtPath:path2x]){ | |
return[self initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path2x]] CGImage] scale:2.0 orientation:UIImageOrientationUp]; | |
} | |
} | |
return[self initWithData:[NSData dataWithContentsOfFile:path]]; | |
} | |
+(UIImage*)imageWithContentsOfResolutionIndependentFile:(NSString*)path { | |
return[[[UIImage alloc] initWithContentsOfResolutionIndependentFile:path] autorelease]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment