Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Created April 30, 2012 20:30
Show Gist options
  • Save RandyMcMillan/2562430 to your computer and use it in GitHub Desktop.
Save RandyMcMillan/2562430 to your computer and use it in GitHub Desktop.
Detect iOS systemVersion and Retina Display
+ (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:@"%@-72@2x.png", resource];
}
}
return resource;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment