1

I am developing universal app for iOS,

I am using Autolayout feature in my app,

I have one doubt:

I want to apply background image in my app, How many background image i will have to make ?? and what will be the naming conventions of the images ? so that iPhone automatically takes corresponding images according to device.

Like we gives on launch images, default@2x.png, Default-568h@2x.png, Default-Portrait@2x.png and device automatically understands it's corresponding images.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Krunal
  • 6,440
  • 21
  • 91
  • 155
  • possible duplicate of [How to support both iPad and iPhone retina graphics in universal apps](http://stackoverflow.com/questions/9611061/how-to-support-both-ipad-and-iphone-retina-graphics-in-universal-apps) – Amar Oct 23 '13 at 11:39

2 Answers2

4

you need 2 types of images for iphone and ipad.

For ipad you just need to add ~ipad before .png.
e.g. image.png for iphone and image~ipad.png for ipad.

Do the same for Retina display images also.

e.g.

iPhone Retina: image@2x.png

iPad Retina: image@2x~ipad.png

Piyush Dubey
  • 2,416
  • 1
  • 24
  • 39
Vaibhav Saran
  • 12,848
  • 3
  • 65
  • 75
  • Use dimension that fits iPhone 5 and if you are putting image through `storyboard` or `xib`, then it will fit automatically. – Vaibhav Saran Oct 23 '13 at 11:56
  • For iPhone again we have 2 type of resolution one for iPhone 4S and other for 5. what will be the resolution of `image@2x.png` ? – Krunal Oct 23 '13 at 11:57
  • what you say, i need to supply only one image for iphone with `640*1136` resolution ?? and it will compress that image in iPhone 4s ?? – Krunal Oct 23 '13 at 11:59
  • If you are adding it with `storyboard/xib` and if your `640x1136` is going to fit in `320x558` screen, then it will automatically shrink for `iphone 4` resolution also. I Think so. Why dont you give it a try! – Vaibhav Saran Oct 23 '13 at 12:02
1

What should help in your case is Asset Catalogs, which are by far the best way to manage assets for multiple devices.

Jonathan Zhan
  • 1,883
  • 1
  • 14
  • 17
  • This is a start of a really good answer. Unfortunately, it is incomplete, because it lacks explicit mention of what OP's asking about . If you could mention that (1) asset catalogs provide compartments for device-specific images, and (2) show a short code snippet that pulls a device-specific image from a resource managed through an asset catalog, your answer would be a lot better. Thanks! – Sergey Kalinichenko Feb 05 '14 at 16:47