user1506841
user1506841

Reputation: 65

Xcode Image Background Swap Device Dependent

Currently I'm defining my app's background image in XCode's Attribute Inspector under Image View.

My view in Attributes Inspector

I'd like to, however, use a different background when an iPhone 5 views the app -- this is for a gaming app so certain screens have tables that I want to make longer. I know this has been written about a lot and some if/then statements are required. My question is: If I've already defined the background image using the Attribute Inspector, is there code to overwrite that which I can add to my .h and .m files?

Here's what I'm thinking: This is the code I'd add to my AppDelegate file:

#define IS_WIDESCREEN (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
#define IS_IPHONE ([[[UIDevice currentDevice]model] isEqualToString:@"iPhone"])
#define IS_IPOD   ([[[UIDevice currentDevice]model] isEqualToString:@"iPod touch"])
#define IS_IPHONE_5 (IS_IPHONE && IS_WIDESCREEN)

This is the code I'd use in my .m file:

if(IS_IPHONE_5) {

    } else {      

}

So here really is what I'm looking for:

  1. Where do I put this code -- do I have to define a new (void) statement?
  2. What code do I use between the { } to call that new image and tell it to display as the background?

Upvotes: 1

Views: 390

Answers (1)

Yo_Its_Az
Yo_Its_Az

Reputation: 2073

simply take the image you want to display instead of your already existant a "[email protected]" with size 640 x 1136 so xcode will automatically use that image when the device is an iphone 5 anywhere your app calls for the "HomeBG.png" image. Hope that helps!

Upvotes: 1

Related Questions