xcode iphone 6 vs iphone 5 图像命名约定
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26160951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iphone 6 vs iphone 5 image Naming Convention
提问by Vikas Rajpurohit
How to set corresponding MYimage.pngfor MyimageViewin Xcode 6 with ios 8.x compatiblity.
如何在兼容 ios 8.x 的 Xcode 6 中为MyimageView设置相应的MYimage.png。
MyimageView setImage:[UIImage imageNamed:@"MYimage.png"];
In Resources, I am having the following images with resolutions:
在资源中,我有以下分辨率的图像:
MYimage.png--320*480
[email protected]*960
[email protected]*1136
[email protected]*1334
[email protected]*2208
For iPhone 4s,it shows: [email protected] [Right]
对于 iPhone 4s,它显示: [email protected] [Right]
For iPhone 5s,it shows: [email protected] [wrong]
对于 iPhone 5s,它显示: [email protected] [wrong]
For iPhone 6,it shows: [email protected] [wrong]
对于 iPhone 6,它显示: [email protected] [wrong]
For iPhone 6+,it shows: [email protected] [wrong]
对于 iPhone 6+,它显示: [email protected] [wrong]
But after renaming the images as mentioned below:
但在重命名图像后,如下所述:
MYimage.png--320*480
[email protected]*960
[email protected]*1136
[email protected]*1334
[email protected]*2208
For iPhone 4s,it shows: [email protected] [Right]
对于 iPhone 4s,它显示: [email protected] [Right]
For iPhone 5s,it shows: [email protected] [wrong]
对于 iPhone 5s,它显示: [email protected] [wrong]
For iPhone 6,it shows: [email protected] [wrong]
对于 iPhone 6,它显示: [email protected] [wrong]
For iPhone 6+,it shows: [email protected] [Right]
对于 iPhone 6+,它显示: [email protected] [Right]
So., What's the stated format to implement?
那么,要实现的规定格式是什么?
Note: Also googled following Linksand so on..
注意:还搜索了以下 链接等..
回答by brandonscript
iOS only supports the size notations for launch images, for example thispage describes the usage for 3.5", 4", and iPads in the format [email protected]
, etc.
的iOS仅支持尺寸为符号发射的图像,例如此页描述了用于3.5"的使用,4" ,和iPads格式[email protected]
等
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.
您实际上只能支持@2x 和@3x(请参阅此处),这解释了为什么在您看到的每台设备上它仅接收@2x 和@3x png。
Lastly, the [email protected]*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 [email protected]
and [email protected]
.
最后,[email protected]*h
也不是有效的大小表示;当您引用名为 的图像时,系统不会自动读取这些文件MYimage.png
;最多你可以做[email protected]
和[email protected]
。
Answering your question below:
下面回答你的问题:
iPhone 6 and iPhone 5 both renderat the same pixel density. UI elements should be positioned correctly in the UI at the same point size on both devices.
iPhone 6 和 iPhone 5 都以相同的像素密度呈现。UI 元素应该在两个设备上以相同的点大小正确定位在 UI 中。
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
).
但是,如果您在 UIImageView 中显示照片,则可以创建最大尺寸并让它缩小到 iPhone 5(使用UIViewContentModeScaleAspectFill
)或保持原样(使用UIViewContentModeCenter
)。
In the end, you reallydon'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.
最后,您真的不想管理每个设备的特定尺寸 - 如果您为每个元素包含 2 个高分辨率资产,那么存储空间就很大了。没有必要为每台设备添加一个,Apple 从未打算如此。
回答by Guilherme
You don't need to specify what screen size the image is for, but only what density it is.
您不需要指定图像的屏幕尺寸,而只需指定它的密度。
There are 3 density groups:
有 3 个密度组:
- 1x: iPhone 3GS and previous; iPod Touch 3rd gen and previous; iPad 2 and previous; iPad Mini 1st gen;
- 2x: iPhones 4, 4S, 5, 5S and 6; iPod Touch 4th and 5th gen; iPad 3 and newer; iPad Mini 2nd gen;
- 3x: iPhone 6 Plus;
- 1x:iPhone 3GS 及之前;iPod Touch 第 3 代及更早版本;iPad 2 及更早版本;iPad Mini 第 1 代;
- 2x:iPhone 4、4S、5、5S 和 6;第 4 代和第 5 代 iPod Touch;iPad 3 及更新版本;iPad Mini 第二代;
- 3x:iPhone 6 Plus;
To each group, you should add an image named with the pattern "[email protected]"
, where the density can be omitted for 1x.
对于每组,您应该添加一个以 pattern 命名的图像"[email protected]"
,其中可以省略 1x 的密度。
Examples:
例子:
- 标志.png
- 标志@2x.png
- 标志@3x.png
For a better use and organization of your image resources, you should consider using Asset Catalogs. They will also help you understand what image sizes you will need depending on what devices you will support, and you will not need to care about each individual file name.
为了更好地使用和组织您的图像资源,您应该考虑使用资产目录。它们还将帮助您了解根据您将支持的设备而需要的图像大小,并且您无需关心每个单独的文件名。