1

As the title says, I'm still confused to understand how image.xcassets handles the iPhone 5/6 images. Let me explain better:

example

This is my MENU_EMPTY_LIST file in image.xcassets. I've been looking for an answer here in stackoverflow and I found this:

  • 1x images are for the original iPhone through the 3GS - 'standard' resolution devices (3.5" screens)

  • 2x images are for the iPhone 4, 4S (3.5" Retina screens) and also iPhone 6.

  • Retina 4 2x are for the iPhone 5 and 5s (4" Retina screens)

  • 3x images are for the new iPhone 6+ (5.5" super-Retina [3x] screen)

This helped me a lot but my question is: what if the image set is a background (in short, an image covering all the screen)? How can I handle the different screen size? What do I have to put into the "2x" square? An iPhone 4/4S image or iPhone 6?

user3582537
  • 414
  • 6
  • 20

1 Answers1

0

only one problem is iPhone 4 and iPhone 6 taking same @2x images.

So, If you want to set perfect image for all the devices then you have to try following code :

if([[UIScreen mainScreen]bounds].size.height==480)
{
    login_bg.image=[UIImage imageNamed:@"i4_login.png"];
}
else if ([[UIScreen mainScreen]bounds].size.height==568)
{
    login_bg.image=[UIImage imageNamed:@"i5_login.png"];
}
else if ([[UIScreen mainScreen]bounds].size.height==667)
{
    login_bg.image=[UIImage imageNamed:@"i6_login.png"];
}
else if ([[UIScreen mainScreen]bounds].size.height==736)
{
    login_bg.image=[UIImage imageNamed:@"i6+_login.png"];
}
else if ([[UIScreen mainScreen]bounds].size.height==1024)
{
    login_bg.image=[UIImage imageNamed:@"ipad_login.png"];
}
Jay Bhalani
  • 4,142
  • 8
  • 37
  • 50