Xcode background-568h@2x.png Not Working

background-568h@2x.png does not work! This is intended, sadly. It’s worth noting that [UIImage imageNamed:@”background.png”] will still only load either “background.png” or “background@2x.png”, it will not load “background-568h@2x.png” if it exists.

To get a background use a proper size for iPhone 5, the infamous 1136×640 you have to change is programmatically. Do this at runtime:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
    // code for 4-inch screen
 // Change you background image here for iPhone 5
} else {
    // code for 3.5-inch screen
}

You can skip the else {} part if you default set the UIImage to background.png it will use @2x automatically as normal. Why Apple didn’t support the -568h convention might be because of avoiding unnecessary lag by checking the size every time for an image. As it will only be few image like the Launch Image and a background image which will use all the screen size.

Posted in ErrorFix, Mac Tagged with: , ,