问题描述
如何使用ios 8.x兼容性在Xcode 6中为 MyimageView 设置相应的 MYimage.png 。
MyimageView setImage:[UIImage imageNamed:@MYimage.png];
在参考资料中,我有以下分辨率的图像:
MYimage.png - 320 * 480
[email protected]*960
MYimage [email protected]*1136
[email protected]*1334
[email protected]* 2208
对于iPhone 4s,它显示: [email protected] [对]
对于iPhone 5s,它显示: [email protected] [错误]
对于iPhone 6,它显示: [email protected] [错误]
对于iPhone 6 +,它显示: [email protected] [错误]
但在重命名图像后,如下所述:
MYimage.png - 320 * 480
[email protected]*960
[email protected]*1136
[email protected] * 1334
[email protected]*2208
For iPhone 4s,显示: [email protected] [右]
对于iPhone 5s,它显示: [email protected] [错误]
对于iPhone 6,它显示: [email protected] [错误]
适用于iPhone 6 +,它显示: [email protected] [右]
那么,实施的陈述格式是什么?
注意:在等等。
iOS仅支持发布图像的大小表示法,例如页面描述了3.5的使用情况, 4,iPad格式为 [email protected]
等。
你是什么实际上只能支持@ 2x和@ 3x(参见)解释了为什么在你看到它的每个设备上它只能获得@ 2x和@ 3x png。
最后, [email protected]*h
也不是有效的大小表示;当您引用名为 MYimage.png
的图像时,系统将不会自动读取这些文件;最多可以 [email protected]
和 [email protected]
。
回答以下问题:
iPhone 6和iPhone 5 渲染 at相同的像素密度。 UI元素应在UI中以两个设备上相同的磅值正确定位。
例如:
iPhone 5 iPhone 6
| | | |
| | | |
| | | |
| [bttn] | | |
| ______ | | [bttn] |
| ________ |
如果您在UIImageView中显示照片,可以创建最大尺寸并让它要么缩小到iPhone 5(使用 UIViewContentModeScaleAspectFill
),要么保持原样(使用 UIViewContentModeCenter
)。 / p>
最后,你真的不想管理每个设备的特定尺寸 - 如果你包括每个元素有2个高分辨率资产,这是一个很大的存储空间。为每个设备添加一个是不必要的,Apple从来没有打算这样做。
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
[email protected]*960
[email protected]*1136
[email protected]*1334
[email protected]*2208
For iPhone 4s,it shows: [email protected] [Right]
For iPhone 5s,it shows: [email protected] [wrong]
For iPhone 6,it shows: [email protected] [wrong]
For iPhone 6+,it shows: [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]
For iPhone 5s,it shows: [email protected] [wrong]
For iPhone 6,it shows: [email protected] [wrong]
For iPhone 6+,it shows: [email protected] [Right]
So., What's the stated format to implement?
Note: Also googled following Links and so on..
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 [email protected]
, 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 [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]
.
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.
这篇关于iphone 6 vs iphone 5 image Naming Convention的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!