Sep26
iPhone 5 / Retina 4 Detection and Asset Modifiers
Retina 4 and the new iPhone 5 doesn’t take any special modifiers. It uses your standard iPhone retina images with the @2x modifier. This is fine for most images as this will give you the behavior you need; however, for full screen images that cannot be vertically tiled you’ll be interested in specifying a different image.
Xcode 4.5 looks for a Default-568b@2x.png splash image but this modifier won’t work for your other assets. It is, however, still a good modifier you can use in your own code to help your organization.
To detect the new Retina 4 device you can use this snippet:
+ (BOOL)isRetina
{
return [[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.f;
}
+ (BOOL)isRetina4
{
return [PTDeviceUtilities isRetina] && [UIScreen mainScreen].bounds.size.height == 568.f;
}
Then you can do dependent image loading like so…
UIImage *backgroundImage;
if ([PTDeviceUtilities isRetina4]) { // iphone5
backgroundImage = [UIImage imageWithCGImage:[[UIImage imageNamed:@"background-568h@2x.png"] CGImage] scale:2.0 orientation:UIImageOrientationUp];
}
else {
backgroundImage = [UIImage imageNamed:@"background.png"];
}
self.window.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];

