1

I have 2 background images built for the specific devices (320x480) and (640x960). I have done the iphone 5 storyboards.

Now, how can I change the background image to the (320x480) version when viewed on a iphone 4?

Note auto layout wouldn't work for me in this case since it's not an alignment issue but rather the image itself.

resting
  • 16,287
  • 16
  • 59
  • 90

3 Answers3

3

Name 320x480 image "background.png" Name 640x960 image "background@2x.png" Name 640x568 image "background-568@2x.png"

then in story boar set background image to "background"

you can also set all these up in an assets.xcassets file in the same image set to simplify.

Augie
  • 1,341
  • 1
  • 11
  • 18
  • Do you mean -568h@2x? It says here in the comment that its only supported by launch images? http://stackoverflow.com/a/12517698/440646 – resting Feb 11 '14 at 06:42
  • @resting I think you're right. 568h@2x only for default image. – Augie Feb 11 '14 at 14:47
1

See How to detect iPhone 5 (widescreen devices)?

Simply set the image in viewDidLoad after you've checked the device

Community
  • 1
  • 1
Jack
  • 16,677
  • 8
  • 47
  • 51
1

I always include these macros inside my .pch file:

#define isiPad  ([[UIScreen mainScreen] bounds].size.height == 1024)?TRUE:FALSE
#define isiPhone4  ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE
#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE

So you can create a switch and set the specific UIImage you need for the screen. I also created a gist with some more useful marc

Alex Cio
  • 6,014
  • 5
  • 44
  • 74