Xcode 6 - Xcassets For Universal Image Support

Xcode 6 - xcassets for universal image support

This is a little confusing - here's how I understand it (this is in reference to the top image):

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

  • 2x images are for the iPhone 4 and 4S (3.5" Retina screens) and are also used for the 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)

I believe that the iPhone 6 (4.7" screen) will use the Retina 4 2x images, but I would have to test it.

Side note, when I create a Launch Image inside my xcassets file, I am shown these options, which basically has all the device I am supporting. Just wondering why this is not also the case when creating an Image Set

If you compare the two images, the lower one has everything the upper one does, except for a 1x iPhone graphic. You don't need that if you're only supporting iOS 7 and above, since iOS 7 doesn't run on any non-Retina phone-form devices. To be honest, I don't understand why the top image has a 1x iPhone form graphic option - maybe because you checked the "iPhone" box in the sidebar?

Also how do you guys approach creating images/sprites for a universal application

For most non-fullscreen images (like a logo), you really only have 3 resolutions to support - standard (1x), Retina (2x), and the iPhone 6+ (3x). These are simply different quality of images, not really different sizes. So if you have a 10x10 image on a standard device, that would mean you need a 20x20 image on a Retina device and a 30x30 image on an iPhone 6+. On all devices, they would show up as a 10x10 image.

A great tool I used for managing different resolutions of icons is iConify.

I create them at the highest size I need (30x30 [@3x] for an image I want to be 10x10 on a device), then save it as a png and resize copies to 20x20 [@2x] and 10x10 [standard]. A better solution would be to create and use vector graphics, which would resize better to any size.

Xcode 6 - universal image support

Assuming that your 640 x 80 image is @2x, the @3x image size would be 960 x 120 (960 = 640 / 2 * 3)

Images.xcassets in Xcode 6

you need to add the images for the 2x & 3x because when you add large size image then at the run time this image get resize as per the actual width of the image it utilize memory lots of memory to do this & some time if your application have too many images then you will get memory issues

if you want to test this then run your application in iPhone 5 then see the memory utilisation by first keeping the high resolution image now take image which will be of appropriate size to iPhone 5 & then run again you will see the difference

so the best practice is to use different image for different size & not images in this fashion.

The answer to your second Question
if you are not adding the splash screen for iPhone 6/6+ then iOS stretches your UI of iphone 5 to fit into the size of the iPhone 6/6+.
But when you add splash screen it stops doing that.

Assets.xcassets - Universal not working

Universal merely means that this app will run on iPad and iPhone natively. Thus the devices on which your app might run can have a single-resolution, double-resolution, or triple-resolution screen.

If you have checked Universal, accordingly, you should see three slots:

Sample Image

Your job, therefore, is to make three versions of your image, sized in proportion. If the 1x is 100x100, the 2x should be 200x200 and the 3x should be 300x300. The version in the appropriate slot will be used at runtime in accordance with the screen resolution of the device we're running on.

The asset catalog does not do any image sizing for you. You have to do it beforehand. (I find Graphic Converter a nice utility for this purpose.)

You could just supply a 3x image and allow the runtime to size down for you, but this is a waste of memory; Apple specifically advises against this in one of the WWDC 2016 videos. So just bite the bullet and make all three image sizes yourself.

Finally:

when I test on my iPad, the images are blurry and aren't as sharp as they are on my iPhone

Hmm, the only reason I can think of for this is that your app is not running natively on the iPad, but is an iPhone app running in "emulation mode" on the iPad. If that's the case, nothing you can do is going to make it look really good. It would be better to write your app as a true Universal app. That is a setting that you make when you create the project initially (though it can be changed later by editing the app target).

How to use xcassets/universal background images for different iPhones/iPads?

Try to check this answer:
How to handle image scale on all the available iPhone resolutions?

You can use this code to configure a different image as well:

NSNumber *screenWidth = @([UIScreen mainScreen].bounds.size.width);
NSString *imageName = [NSString stringWithFormat:@"name-%@w", screenWidth];
UIImage *image = [UIImage imageNamed:imageName];

Images.xcassets taking wrong image for the iPhone 6?

This is ridiculous from apple.

There is no any specific place where you can put the iPhone 6 images. you have to do with the condition.



Related Topics



Leave a reply



Submit