Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 how to set separate @2x images for iPhone 5 and 6 devices?

I want to specify different background images for iPhone each device. Like this

iPhone 6 Plus   1242x2208 pixels    [email protected]
iPhone 6        750x1334  pixels    [email protected]
iPhone 5        640x1136  pixels    [email protected]
iPhone 4        640x960   pixels    [email protected]
iPhone 3GS      320x480   pixels    bg.png

In LaunchImage there is option available to specify images for Retina HD 4.7 device. So no problem for Launch Images.

enter image description here

In .xcassets file, I have option for 1x, 2x, Retina 4 2x and 3x. But there is no option for iPhone 6 (1334x750) device.

enter image description here

So how to provide 1334x750 px image for iPhone 6 device? Looking for some solution using .xcassets file, not by programmatically loading images for each device.

I have already visited the related SO's questions, but none of them answers specifically for iPhone 6 device images.

iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development

xcode 6 asset catalog iphone 6

like image 952
Khawar Avatar asked Nov 11 '14 06:11

Khawar


2 Answers

set your image name like this;

image-320@2x//iPhone 5

image-375@2x//iPhone 6

NSNumber *screenWidth = @([UIScreen mainScreen].bounds.size.width);
NSString *imageName = [NSString stringWithFormat:@"image-%@", screenWidth];
UIImage *image = [UIImage imageNamed:imageName];
like image 103
Valar Morghulis Avatar answered Oct 14 '22 01:10

Valar Morghulis


Images.xcassets has option to provide separate image for iPhone 5(Retina 4 @2x), iPhone 6(@2x) and iPhone 6 plus(3x).

enter image description here

There is no option for iPhone 4 asset(probably apple is stopping iPhone 4 support) rather it takes @2x images (scale mode) for iPhone 4 also but you can do something like This post for iPhone 4

Update Xcode 7

There is no option for separate image with Images.xcassets now in Xcode 7, We have to use same 2x images for all Retina devices and 3x for Retina HD device

like image 37
Abhishek Avatar answered Oct 14 '22 01:10

Abhishek