Understanding iPhone 5/6 resolution on image.xcassets - ios

As the title says, I'm still confused to understand how image.xcassets handles the iPhone 5/6 images. Let me explain better:
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?

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"];
}

Related

Xcode Image Asset By Device

My question relates to creating a custom image asset for iPad Pro. It is my understanding that the correct image from an image asset set in Xcode is picked based on the type of device in the following way:
iPhone:
1x: iPhones older than iPhone 4
2x: iPhone 4/4s, 5/5s, 6/6s
3x: iPhone 6/6s Plus
iPad:
1x: non-retina iPads
2x: retina iPads (including iPad mini)
If this understanding is incorrect, please let me know. But if it is correct, how do I make a custom image set for iPad Pro? The images I made for the regular-size retina iPad would be too small to fit on the iPad Pro and there is no 3x option for an iPad image set.

iOS- Image resource for iPhone 6 and 6 plus

I am developing portrait resolution app which will support all iPhone screens. I am not scaling so i have to cater every Screen size. iPhone 6 plus have 1242 x 2208 (#3x) for portrait and iPhone 6 have 750 x 1334 (#2x) for portrait.
Normally i would create full width image graphics in 320#1x, 640#2x and 960#3x. But now it wont work. Do i have to make full width sized images separate for every resolution?
Like i would create 640#2x for iPhone 5s or earlier and 750#2x for iPhone 6 and 1242#3x for iPhone 6 plus.
Do i have to make different images for every resolution? Am i going in right Direction or there is a better solution?
The iPhone 6 and iPhone 5 uses the same #2x images, but as the resolution is different on both the devices it's best practice to get the different images for both.
On iPhone 6, if the image of iPhone 5 will be loaded then you will see some distortion.
On other hand, if you have image of 750 x 1334 (#2x) for iPhone 6 and if you will load that ion iPhone 5 or 4 then you will see squeeze image as it is of higher resolution.
But the problem is that if you put both iPhone_5#2x and iPhone_6#2x then Xcode will not that which image to be loaded on which device. So, for that I have made a function to differentiate the images at runtime.
//MARK: Load Images for particular device
func getDeviceSpecificImage(imgName: String) -> String{
var imageName: String?
switch UIScreen.mainScreen().bounds.width{
case 320:
imageName = String(format: "%#_5#2x", imgName)
case 375:
imageName = String(format: "%#_6#2x", imgName)
case 414:
imageName = String(format: "%#_6+#3x", imgName)
default:
break
}
return imageName!
}
Hope this helps!

iOS #2x images conflicting

I've a little confusion and facing a little problem regarding #2x images in iOS as according to Human Interface Guidelines HIG, the #2x For iPhone 6: 750 x 1334 (#2x) for portrait but same #2x for iPhone 4S has size of 640x1136.
HIG
When I placed #2x image named as MyTestImage#2x.png of size 750 x 1134, it was fine for iPhone 6 but not for iPhone 4S, but if I put MyTestImage#2x.png of size 640x1136 then its fine for iPhone 4S but not for iPhone 6.
I also placed 640x1136 as Retina 4 2x named as MyTestImage-568h#2x.png but its also not working for me.
Whats I'm conflicting? What should be the actual image sizes of #2x for iPhone 4S and iPhone 6 if I talk about a full screen image.
And also what should be the correct retina display image size.
EDIT 1:
My question is different as I want to know the difference between #2x and -568h#2x retina display regarding both screens. Also, any optimal solution for this which can avoid image redundancies.

Sprite Kit art assets naming convention

Making my 1st Sprite Kit game & almost finished it. Just getting my images finalized. Problem is, with the addition of iPhone 6 & 6 Plus, I am having issues figuring out how to name my game assets. For instance, one of my several background images is called "1MBack.png". Sometimes people write "Default–568h#2x.png" and I try to figure out if I need the "Default–568h" part in my game asset names. The naming convention I used for my art is as following:
<< 1x (iPhone 2G, 3G, 3GS) = 1MBack.png >> << 2x (iPhone 4, 4s) = 1MBack#2x.png (640x1136) >> << Retina 4 2x (iPhone 5, 5s) = 1MBack#2x.png (750x1334) >> << 3x (iPhone 6 Plus) = 1MBack#3x.png >>
Did I name my image's correctly? What about iPhone 6 - do I name an image for it 1MBack#2x.png or 1MBack-667h#2x.png? It's important to me to get these names right because I sat for quite a while making each asset for each screen and want them utilized accordingly.
One final question: when making the assets in photoshop, as I was sizing them, I choose PPI according to the PPI of the screen the asset would be used on. So the 1x (iPhone 2G, 3G, 3GS) 1MBack.png has a PPI of 163. The 2x (iPhone 4, 4s) 1MBack#2x.png has a PPI of 326. Is this correct? I'm worried about this also, because I read someone writing to make assets in PPI 72. Please clarify this.
Set different name for Widescreen images(new iPhones) like name-retina
-(void)didMoveToView:(SKView *)view
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
CGSize result = [[UIScreen mainScreen] bounds].size;
if (result.height == 480) {//Old iPhone detected
SKSpriteNode *bg = [SKSpriteNode spriteNodeWithImageNamed:#"1MBack"];//2G, 3G, 3GS
//By the way you have to set different sprite position for devices here
}else{//New iPhone detected
SKSpriteNode *bg = [SKSpriteNode spriteNodeWithImageNamed:#"1MBack-retina"];//5, 5S, 6, 6Plus
}
}
}

Image Sizes for Supporting iPhone 4S,5,5C/S,6 and 6+

I want to support a variety of devices from iPhone 4S to iPhone 6+. Previously, when adding supporting for iPhone 5, we followed the following steps.
Add the launch Default-568h#2x.png
Use the same #2x images (640x960) which are resized automatically for iPhone 5.
Now, iPhone 6 and 6+ are introduced with varying sizes and it is written on most blogs that we will use #2x for iPhone 6 and #3x identifier for iPhone 6+. It is also written that:
iPhone 6+ (#3x) images will have resolution of 1242x2208 (I am using portrait mode), and it is automatically downsized.
iPhone 6 will use #2x images.However,I am not sure what the size of these images should be. Should they be 640x960 or 640x1136 or 750 x 1334. In case of using the first two sizes, won't the images be distorted?
I think what you are after is detailed in the HIG under "Icon and Image Sizes"
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW1

Resources