Search code examples
xcodeinterfaceinterface-builderiphone-5

Xcode - Interface Builder and iPhone 5 images


I'm using IB to assign images to UIImageViews. I know that for retina images you need two images: the non-retina resolution .png and the @2x.png. I just assign the normal image in IB and when the device is retina it gets the @2x, everything OK.

But how about the iPhone 5 images? Is there some kind of suffix for IB to read and swap the image as well?


Solution

  • The short answer is no.

    You can use:

    #define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES) 
    

    to check if the user is using iPhone 5 or not.

    In some cases I use the iPhone 5 image as the @2x picture to avoid the check above. The iPhone 5 user will get a full resolution picture and the iPhone 4 user will get the same picture but with an hidden lower part.