Created
April 30, 2012 20:30
-
-
Save RandyMcMillan/2562430 to your computer and use it in GitHub Desktop.
Detect iOS systemVersion and Retina Display
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
+ (NSString*) resolveImageResource:(NSString*)resource | |
{ | |
NSString* systemVersion = [[UIDevice currentDevice] systemVersion]; | |
BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending); | |
// the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path | |
if (isLessThaniOS4) | |
{ | |
return [NSString stringWithFormat:@"%@.png", resource]; | |
} | |
else { | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES && [[UIScreen mainScreen] scale] == 2.00) { | |
return [NSString stringWithFormat:@"%@[email protected]", resource]; | |
} | |
} | |
return resource; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment