What is the new naming convention for images for the 4-inch retina display?
For an image named background.png
you add @2x to the name ([email protected]
) to tell iOS to use that one for devices with the retina display.
What would the suffix be for iPhone 5's screen size?
You can use my #define
s to help you with these images:
#define isPhone568 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568) #define iPhone568ImageNamed(image) (isPhone568 ? [NSString stringWithFormat:@"%@-568h.%@", [image stringByDeletingPathExtension], [image pathExtension]] : image) #define iPhone568Image(image) ([UIImage imageNamed:iPhone568ImageNamed(image)])
Just give your images the [email protected] notation, and use iPhone568ImageNamed
to get a name for standard name or iPhone 5/new iPod.
Usage example from the comments:
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:iPhone568ImageNamed(@"mainscreen.png")]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With