27

Mostly every iOS application has a view with an image as background. Is there any image sizing guide out there? For example here is an iOS screen designed in Sketch:

enter image description here

As you can see there is a background image. Now there are lots of Apple devices every application should support. The new iOS 10 supports all devices from iPhone 5 to iPhone 6s Plus. They have different screen sizes and resolutions. When creating Xcode assets, I am giving 3 background images with different sizes - @1x, @2x, @3x. What sizes should they be?

Nikita Zernov
  • 5,465
  • 6
  • 39
  • 70

7 Answers7

28

The way I see it you have 2 options:

  1. In here you will find the resolutions of the iPhone's:

iphone screen resolutions

  • You don't need the @1 image since you don't support iPhone 4 and 4s (iOS 10).
  • @2 is for iPhone 5,5c,5S,6 and 6s so basically you can create @2 image of the highest resolution which is the iPhone 6 and this image will work well for the iPhone 5 family.
  • Or, you can create an image with resolution for each iPhone and using hard coded logic set the image for each phone. i.e: if iphone5c { setImage("iphone5cImage") } etc etc..

  1. The simplest solution is to create 1 image with the highest resolution. The @3 is the highest for the iPhone 6S+ and it will look amazing for the rest. Don't forget to set the image view as aspect fill.

Also, don't forget to check this thread: How to handle image scale on all the available iPhone resolutions?. It will give you clues of what exactly you are dealing with. TL;DR, It's the options I wrote.

OhadM
  • 4,687
  • 1
  • 47
  • 57
  • I believe you are incorrect associating '@1' with iPhone 4 and 4s, '@2' is iPhone 4 and 4s, see here https://stackoverflow.com/a/32355413/1258525 – Brian Ogden Jun 11 '17 at 04:00
  • @BrianOgden, According to Apple: https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/ I am not mistaken. Also, you can take a look at a relevant answer here: https://stackoverflow.com/a/32355413/4260691 answer updated – OhadM Jun 23 '17 at 15:56
  • Also, don't forget that he wants iOS 10 + and iPhone 4S is up to 9: https://en.wikipedia.org/wiki/IPhone_4S – OhadM Jun 23 '17 at 16:00
  • What about landscape sizes? – Ash Oct 31 '17 at 04:46
  • @Ash, I'd use the same logic but for landscape – OhadM Oct 31 '17 at 08:24
17

The background images you only need to give are @2x and @3x, because @1x devices are now long gone in the dusty pages of history.

Speaking of @2x and @3x, the image resolutions you give to the developer should be the same with the highest resolution iPhone that uses that given size.

For @2x, that is the iPhone 6, which is 750x1334, and for @3x, the iPhone 6+ which is 1242x2208.

Down-scaling shouldn't be a problem because the aspect ratios of all iPhones that support iOS 10 are the same(16:9).

Note for Developer(s):

The UIImageView will then down-scale the images appropriately,
provided: 

1. you created an image set with the provided @2x and @3x images, 
2. correctly constrainted the UIImageView to the edges of the superview, and
3. selected the Content Mode of the UIImageView as Scale to Fill or Aspect Fill.
sergeng
  • 736
  • 4
  • 10
  • Nice answer, but this is out of date in the meanwhile. The aspect ratio of iPhones was 16:9 until the physical homebutton disappeared. iPhone X and all newer iPhones have an aspect ratio of 19.5:9. – pascalre Dec 22 '21 at 19:22
2

There is design nuance in full size background images. Mostly if the scale aspect fill good enough for different sizes you need to design only for the biggest device size after that the rest of them scale to fit. Sometimes some part of background needs to remain visible or if want to keep a low memory footprint for small device sets you need to create smaller alternatives.

Whenever you make a decision with the design size of asset you need to create @3x,@2x variants.

One more thing I need to point out about vector designs. If your design is made only with vectors you can choose pdf vector export. Storyboards can accept vector assets and they are doing very good when scaling in full backgrounds.

Declan McKenna
  • 4,321
  • 6
  • 54
  • 72
Ali Kıran
  • 1,006
  • 7
  • 12
1

Take a look at the page on documentation, there is Static Launch Screen Images, and you can catch sizes from there.

You can get a device screen size, using

CGSize screenSize = [UIScreen mainScreen].bounds.size // (Objective-C)


let screenSize: CGSize = UIScreen.mainScreen().bounds.size // (Swift)

And after you can programmatically select an image you want, from set of an images from the bundle. Or to make a big one image for resizing, using knowledges from documentation, and to resize an image accordingly. Or...your choice.

Different "sizes" @2x, @3x is scale. And here is the nice explanation.

Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
1

I use background images in my Apps. To solve this problem I use one image that has the resolution to cover all iPhones and all the iPads except the large one. The image size is 2048x2048 points or 1024x1024 pixels at @2x to cover the 9.7 inch iPad.

The image is compressed JPG to keep the size down. Note that I allow it to scale for iPhone 6 Pluse (@3x) and 12.7 inch iPad Pro (@2x) as the quality doesn't seem to be affected. I can justify the scaling for the larger devices, because if I provided image for the 12.7 inch iPad Pro, it will be 5464x4096 points (@2x) and 2732x2048 pixels and then the JPG compression would have to be so high (if I wanted to keep the size down), that the quality of the image was low anyway compared with scaling.

If you need high quality try both JPG and PNG for comparison, because the PNG becomes very large for complex images, but gives the best quality.

Sverrisson
  • 17,970
  • 5
  • 66
  • 62
  • can you clearify me one thing.the images @2x,@3x are genrated at build time for the app?Else it will be a headache to scale the image at runtime.it will makes the app slow. – Muhammad Zohaib Ehsan Jul 14 '16 at 18:10
  • and i have another question. it will make the image contracted? – Muhammad Zohaib Ehsan Jul 14 '16 at 18:13
  • @MuhammadZohaibEhsan The images are scaled automatically, i.e. if 3x is needed the 2x is used etc. This will only affect your app at the start, but I have not seen much time difference effect. You can try out letting the system scale a lightweight JPG, compared with loading a PNG at full quality. In this case I think the much larger file will take longer as the bottleneck will be loading from the disk, instead of scaling. And if your app goes to the background then large images may be deallocated to free memory so, I think using JPG is your best option. – Sverrisson Jul 14 '16 at 20:13
  • If I am looking to support iPhone family only that too above 5C, will 2048x2048 cover all of them? Event iPhoneX? I am assuming UIIMageView would have to set to AspectFill – nr5 Jul 04 '18 at 12:52
  • @Nil iPhone X is 1125 x 2436 px and thus you would need at least 2436 x 2436 px to cover landscape also. The sizes are here: https://stackoverflow.com/questions/25755443/iphone-6-plus-resolution-confusion-xcode-or-apples-website-for-development/25755757#25755757 – Sverrisson Jul 04 '18 at 16:30
1

If you still have the same problem then you can try this one. For this you have to add only one image with good resolution and below code..

UIImage *bgImage = [UIImage imageNamed:@"art_background_star@3x.jpg"];
CGSize screenSize = [UIScreen mainScreen].bounds.size;
UIGraphicsBeginImageContextWithOptions(screenSize, NO, 0.f);
[bgImage drawInRect:CGRectMake(0.f, 0.f, screenSize.width, screenSize.height)];
UIImage * resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIColor *backgroundColor = [UIColor colorWithPatternImage:resultImage];
self.view.backgroundColor = backgroundColor;
Rishabh
  • 391
  • 3
  • 13
1

enter image description here

There are 3 kinds of Apple Devices (iPhone and iPad) that is

Normal device which terms to 1 pixel = 1 point@1x (Older iPhone and iPad devices)

Retina device which terms to 4 pixels(2 x 2) = 1 point@2x (iPhone 5+)

Retina iPhone6 and iPad which terms to 9 pixels (3 x 3) = 1 point@3x (iPhone6+)

enter image description here

For iOs 10 that will not support iPhone 4s so you only require @2x and @3x images.

As you can see above attached image iPhone 6 also support @2x Scale so use image size for @2x is of 750*1334 and for @3x is of 1242*2208 with image mode.

Bhoomi Jagani
  • 2,413
  • 18
  • 24