ios 新 iPhone 6 和 6+ 的图像分辨率,添加了@3x 支持?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25781422/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:21:54  来源:igfitidea点击:

Image resolution for new iPhone 6 and 6+, @3x support added?

iosresolutioniphone-6iphone-6-plus

提问by Bhumit Mehta

I have looked on few articles and discussion like one hereand Hereabout image resolutions that new iPhones will use @3x images for display. Is it true?

我看过几篇文章和讨论,就像这里这里关于新 iPhone 将使用 @3x 图像显示的图像分辨率。这是真的吗?

So does it mean we will have to keep three images? Say for example I have an image of 50 X 50, will I have to keep 3 images for optimizing the look for new iPhones?

那么这是否意味着我们必须保留三个图像?比如说我有一张 50 X 50 的图像,我是否必须保留 3 张图像来优化新 iPhone 的外观?

  • Normal (50 X 50)
  • @2x - Retina (100 X 100)
  • @3x - Retina HD (150 X 150)
  • 普通 (50 X 50)
  • @2x - 视网膜 (100 X 100)
  • @3x - 视网膜高清 (150 X 150)

Or will the new phones use @2x images only and there is nothing like @3x?

或者新手机只会使用@2x 图像而没有像@3x 这样的图像?

I have tested by making a sample project and all simulators seem to use @3x images, this is confusing.

我通过制作示例项目进行了测试,所有模拟器似乎都使用@3x 图像,这令人困惑。

Edit

编辑

Here is some more info

这是更多信息

  • 3GS ( 163 ppi so use Normal)
  • 4, 4s, 5 and 5s (326 ppi so we use @2x)
  • 6 (326 ppi so it seems like it will use @2x)
  • 6 plus (401 ppi here lies the confusion )
  • 3GS(163 ppi 所以使用普通)
  • 4、4s、5 和 5s(326 ppi,所以我们使用 @2x)
  • 6(326 ppi,所以看起来它会使用@2x)
  • 6 plus(401 ppi 是混乱所在)

Edit

编辑

Based on Answers given by Tsob and nitin, I added @3x images to my project.

根据 Tsob 和 nitin 给出的答案,我在我的项目中添加了 @3x 图像。

Informational Edit

信息编辑

I see few users are confused about why iPhone 6 uses @2x images even though it has higher resolution , the reason is

我看到很少有用户对为什么 iPhone 6 使用 @2x 图像即使它具有更高的分辨率感到困惑,原因是

iPhone 6 might have different resolution but has same density of per pixel inch (PPI)

iPhone 6 的分辨率可能不同,但每像素英寸 (PPI) 的密度相同

  • Resolutionconcerns an absolute number of pixels.
  • Density(aka Pixels per inch - PPI) concerns a relative number of pixels per inch which is same in case of iPhone 6 and previous iPhones , but different in iPhone 6 plus.
  • 分辨率涉及像素的绝对数量。
  • 密度(又名每英寸像素数 - PPI)涉及每英寸像素的相对数量,这与 iPhone 6 和之前的 iPhone 相同,但在 iPhone 6 plus 中不同。

Check more about this here in this thread

在此线程中查看更多相关信息

Hence iPhone 6 uses @2x image same as iPhones 4 , 5 and 5S as it has same PPI and iPhone 6 plus uses @3x.

因此,iPhone 6 使用与 iPhone 4、5 和 5S 相同的 @2x 图像,因为它具有相同的 PPI,而 iPhone 6 plus 使用 @3x。

采纳答案by TSob

I've tried in a sample project to use standard, @2x and @3x images, and the iPhone 6+ simulator uses the @3x image. So it would seemthat there are @3x images to be done (if the simulator actually replicates the device's behavior). But the strange thing is that all devices (simulators) seem to use this @3x image when it's on the project structure, iPhone 4S/iPhone 5 too.
The lack of communication from Apple on a potential @3x structure, while they ask developers to publish their iOS8 apps is quite confusing, especially when seeing those results on simulator.

我曾在示例项目中尝试使用标准、@2x 和 @3x 图像,而 iPhone 6+ 模拟器使用 @3x 图像。所以似乎有@3x 图像要完成(如果模拟器实际上复制了设备的行为)。但奇怪的是,所有设备(模拟器)在项目结构上似乎都使用这个@3x 图像,iPhone 4S/iPhone 5 也是如此。
Apple 在潜在的 @3x 结构上缺乏沟通,而他们要求开发人员发布他们的 iOS8 应用程序,这非常令人困惑,尤其是在模拟器上看到这些结果时。

**Edit from Apple's Website **: Also found this on the "What's new on iOS 8" section on Apple's developer space :

**来自 Apple 网站的编辑 **:也在 Apple 开发人员空间的“iOS 8 上的新功能”部分找到了这个:

Support for a New Screen ScaleThe iPhone 6 Plus uses a new Retina HD display with a screen scale of 3.0. To provide the best possible experience on these devices, include new artwork designed for this screen scale. In Xcode 6, asset catalogs can include images at 1x, 2x, and 3x sizes; simply add the new image assets and iOS will choose the correct assets when running on an iPhone 6 Plus. The image loading behavior in iOS also recognizes an @3x suffix.

支持新的屏幕比例iPhone 6 Plus 使用新的 Retina HD 显示屏,屏幕比例为 3.0。为了在这些设备上提供最佳体验,请添加为此屏幕比例设计的新图稿。在 Xcode 6 中,资产目录可以包含 1x、2x 和 3x 尺寸的图像;只需添加新的图像资产,iOS 就会在 iPhone 6 Plus 上运行时选择正确的资产。iOS 中的图像加载行为也识别 @3x 后缀。

Still not understanding why all devices seem to load the @3x. Maybe it's because I'm using regular files and not xcassets ? Will try soon.

仍然不明白为什么所有设备似乎都加载了@3x。也许是因为我使用的是常规文件而不是 xcassets ?很快就会尝试。

Edit after further testing :Ok it seems that iOS8 has a talk in this. When testing on an iOS 7.1 iPhone 5 simulator, it uses correctly the @2x image. But when launching the same on iOS 8 it uses the @3x on iPhone 5. Not sure if that's a wanted behavior or a mistake/bug in iOS8 GM or simulators in Xcode 6 though.

进一步测试后编辑:好的,iOS8 似乎对此有发言权。在 iOS 7.1 iPhone 5 模拟器上进行测试时,它正确使用了 @2x 图像。但是当在 iOS 8 上启动它时,它在 iPhone 5 上使用 @3x。不过不确定这是想要的行为还是 iOS8 GM 或 Xcode 6 模拟器中的错误/错误。

回答by Nitin Gohel

UPDATE:

更新:

New link for the icons image size by apple.

苹果图标图像大小的新链接。

https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/

https://developer.apple.com/ios/human-interface-guidelines/graphics/image-size-and-resolution/

enter image description here

在此处输入图片说明



Yes it's True here it is Apple provide Official documentation regarding icon's or image size

是的,这是真的,这是 Apple 提供有关图标或图像大小的官方文档

enter image description here

在此处输入图片说明

you have to set images for iPhone6 and iPhone6+

你必须为 iPhone6 和 iPhone6+设置图像

For iPhone 6:

对于 iPhone 6:

750 x 1334 (@2x) for portrait

1334 x 750 (@2x) for landscape

For iPhone 6 Plus:

对于 iPhone 6 Plus:

1242 x 2208 (@3x) for portrait

2208 x 1242 (@3x) for landscape

For more info regarding Images and it's resolution this is best ever helpful post

有关图像及其分辨率的更多信息,这是有史以来最好的有用帖子

For setting images size for controls you can set 1x @2x and @3x like following:

要设置控件的图像大小,您可以设置 1x @2x 和 @3x,如下所示:

enter image description here

在此处输入图片说明

回答by matt

I have tested by making a sample project and all simulators seem to use @3x images , this is confusing.

我通过制作示例项目进行了测试,所有模拟器似乎都使用 @3x 图像,这令人困惑。

Create different versions of an image in your asset catalog such that the image itself tells you what version it is:

在您的资产目录中创建不同版本的图像,以便图像本身告诉您它是什么版本:

enter image description here

在此处输入图片说明

Now run the app on each simulator in turn. You will see that the 3x image is used only on the iPhone 6 Plus.

现在依次在每个模拟器上运行应用程序。您会看到 3x 图像仅用于 iPhone 6 Plus。

The same thing is true if the images are drawn from the app bundle using their names (e.g. one.png, [email protected], and [email protected]) by calling imageNamed:and assigning into an image view.

如果图像是使用它们的名称(例如one.png[email protected][email protected])通过调用imageNamed:并分配到图像视图中从应用程序包中提取的,则同样如此。

(However, there's a difference if you assign the image to an image view in Interface Builder - the 2x version is ignored on double-resolution devices. This is presumably a bug, apparently a bug in pathForResource:ofType:.)

(但是,如果您将图像分配给 Interface Builder 中的图像视图会有所不同 - 在双分辨率设备上忽略 2x 版本。这可能是一个错误,显然是pathForResource:ofType:.)

回答by Bastian

ios will always tries to take the best image, but will fall back to other options .. so if you only have normal images in the app and it needs @2x images it will use the normal images.

ios 将始终尝试拍摄最佳图像,但会退回到其他选项。

if you only put @2x in the project and you open the app on a normal device it will scale the images down to display.

如果您只将@2x 放在项目中并在普通设备上打开应用程序,它将缩小图像以显示。

if you target ios7 and ios8 devices and want best quality you would need @2x and @3x for phone and normal and @2x for ipad assets, since there is no non retina phone left and no @3x ipad.

如果您的目标是 ios7 和 ios8 设备并希望获得最佳质量,您需要@2x 和@3x 用于电话和普通资产,@2x 用于ipad 资产,因为没有非视网膜电话,也没有@3x ipad。

maybe it is better to create the assets in the app from vector graphic... check http://mattgemmell.com/using-pdf-images-in-ios-apps/

也许最好从矢量图形在应用程序中创建资产...检查http://mattgemmell.com/using-pdf-images-in-ios-apps/