Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

ios - iphone 6 vs iphone 5 image Naming Convention

How to set corresponding MYimage.png for MyimageView in Xcode 6 with ios 8.x compatiblity.

MyimageView setImage:[UIImage imageNamed:@"MYimage.png"];

In Resources, I am having the following images with resolutions:

MYimage.png--320*480

MYimage@2x.png--640*960

MYimage-568h@2x.png--640*1136

MYimage-375h@2x.png--750*1334

MYimage-736h@3x.png--1242*2208

For iPhone 4s,it shows: MYimage@2x.png [Right]

For iPhone 5s,it shows: MYimage@2x.png [wrong]

For iPhone 6,it shows: MYimage@2x.png [wrong]

For iPhone 6+,it shows: MYimage@2x.png [wrong]

But after renaming the images as mentioned below:

MYimage.png--320*480

MYimage@2x.png--640*960

MYimage-568h@2x.png--640*1136

MYimage-375h@2x.png--750*1334

MYimage@3x.png--1242*2208

For iPhone 4s,it shows: MYimage@2x.png [Right]

For iPhone 5s,it shows: MYimage@2x.png [wrong]

For iPhone 6,it shows: MYimage@2x.png [wrong]

For iPhone 6+,it shows: MYimage@3x.png [Right]

So., What's the stated format to implement?

Note: Also googled following Links and so on..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

iOS only supports the size notations for launch images, for example this page describes the usage for 3.5", 4", and iPads in the format Default-568h@2x.png, etc.

What you're actually only able to support is @2x and @3x (see here) which explains why on each of the devices you're seeing it pick up the @2x and @3x pngs only.

Lastly, the MYimage@Xx.png--w*h isn't a valid size denotation either; those files won't be read by the system automatically when you reference an image named MYimage.png; at most you could do MYimage@2x.png and MYimage@3x.png.

Answering your question below:

iPhone 6 and iPhone 5 both render at the same pixel density. UI elements should be positioned correctly in the UI at the same point size on both devices.

For example:

iPhone 5       iPhone 6
|      |      |        |
|      |      |        |
|      |      |        |
|[bttn]|      |        |
|______|      | [bttn] |
              |________|

If you're displaying an photo in a UIImageView though, you can just create the largest size and let it either scale down to the iPhone 5 (using UIViewContentModeScaleAspectFill) or leave it as-is (using UIViewContentModeCenter).

In the end, you really don't want to have to manage specific dimensions for every single device out there - already if you're including 2 high-res assets for each element, that's a lot of storage space. Adding one for every device is unnecessary, and Apple never intended for that to be the case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...