ios iPhone 6 Plus 分辨率混淆:Xcode 还是 Apple 的网站?发展

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

iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development

iosxcodeios-simulatoriphone-6iphone-6-plus

提问by JasonGenX

Apple's website claims that the resolution is 1080p: 1920 x 1080

Apple 网站声称分辨率为 1080p:1920 x 1080

However, the launch screen required by Xcode (8.0 GM launched today) is 2208 x 1242.

但是Xcode(今天推出8.0 GM)要求的启动画面是2208 x 1242。

Who's right?

谁是对的?

Xcode

Xcode

回答by Tommy

The iPhone 6+ renders internally using @3xassets at a virtual resolution of 2208×1242(with 736x414points), then samples that down for display. The same as using a scaled resolution on a Retina MacBook — it lets them hit an integral multiple for pixel assets while still having e.g. 12 pt text look the same size on the screen.

iPhone 6+ 在内部使用@3x资源以2208×1242736x414点)的虚拟分辨率进行渲染,然后对其进行采样以进行显示。与在 Retina MacBook 上使用缩放分辨率相同——它可以让像素资产达到整数倍,同时仍然具有例如 12 pt 文本在屏幕上看起来相同的大小。

So, yes, the launch screens need to be that size.

所以,是的,启动屏幕需要是那个大小。

The maths:

数学:

The 6, the 5s, the 5, the 4s and the 4 are all 326 pixels per inch, and use @2x assets to stick to the approximately 160 points per inch of all previous devices.

6、5s、5、4s 和 4 都是每英寸 326 像素,并使用 @2x 资产坚持所有以前设备的每英寸大约 160 点。

The 6+ is 401 pixels per inch. So it'd hypothetically need roughly @2.46x assets. Instead Apple uses @3x assets and scales the complete output down to about 84% of its natural size.

6+ 是每英寸 401 像素。因此,假设它大约需要@2.46x 资产。相反,Apple 使用@3x 资产并将完整输出缩小到其自然大小的 84% 左右。

In practice Apple has decided to go with more like 87%, turning the 1080 into 1242. No doubt that was to find something as close as possible to 84% that still produced integral sizes in both directions — 1242/1080 = 2208/1920 exactly, whereas if you'd turned the 1080 into, say, 1286, you'd somehow need to render 2286.22 pixels vertically to scale well.

在实践中,Apple 决定采用更多的 87%,将 1080 变成 1242。毫无疑问,这是为了找到尽可能接近 84% 的东西,仍然在两个方向上产生整数大小——1242/1080 = 2208/1920 ,而如果你把 1080 变成了,比如说,1286,你就需要以某种方式垂直渲染 2286.22 像素才能很好地缩放。

回答by Sverrisson

The answer is that older apps run in 2208 x 1242 Zoomed Mode. But when an app is built for the new phones the resolutions available are: Super Retina HD 5.8 (iPhone X) 1125 x 2436 (458ppi), Retina HD 5.5(iPhone 6, 7, 8 Plus) 1242 x 2208and Retina HD 4.7(iPhone 6) 750 x 1334. This is causing the confusion mentioned in the question. To build apps that use the full screen size of the new phones add LaunchImages in the sizes: 1125 x 2436, 1242 x 2208, 2208 x 1242 and 750 x 1334.

答案是较旧的应用程序在 2208 x 1242 缩放模式下运行。但是当为新手机构建应用程序时,可用的分辨率为:Super Retina HD 5.8 (iPhone X) 1125 x 2436 (458ppi)Retina HD 5.5( iPhone 6、7、8 Plus) 1242 x 2208Retina HD 4.7( iPhone 6) 750 x 1334。这导致了问题中提到的混淆。要构建使用新手机全屏尺寸的应用程序,请添加以下尺寸的 LaunchImages:1125 x 2436、1242 x 2208、2208 x 1242 和 750 x 1334。

Updated for the new iPhones 11, 11 Pro, 11 Pro Max

针对新款 iPhone 11、11 Pro、11 Pro Max 进行了更新

Size for iPhone 11 Pro Maxwith @3xscaling, coordinate space: 414 x 896points and 1242 x 2688pixels, 458 ppi, device physical size is 3.06 x 6.22 in or 77.8 x 158.0 mm. 6.5" Super Retina XDR display.

iPhone 11 Pro Max尺寸,@3x缩放,坐标空间:414 x 896点和1242 x 2688像素,458 ppi,设备物理尺寸为 3.06 x 6.22 英寸或 77.8 x 158.0 毫米。6.5" 超级视网膜 XDR 显示屏。

Size for iPhone 11 Prowith @3xscaling, coordinate space: 375 x 812points and 1125 x 2436pixels, 458 ppi, device physical size is 2.81 x 5.67 in or 71.4 x 144.0 mm. 5.8" Super Retina XDR display.

iPhone 11 Pro尺寸,@3x缩放,坐标空间:375 x 812点和1125 x 2436像素,458 ppi,设备物理尺寸为 2.81 x 5.67 英寸或 71.4 x 144.0 毫米。5.8 英寸超级视网膜 XDR 显示屏。

Size for iPhone 11with @2xscaling, coordinate space: 414 x 896points and 828 x 1792pixels, 326 ppi, device physical size is 2.98 x 5.94 in or 75.7 x 150.9 mm. 6.1" Liquid Retina HD display.

iPhone 11尺寸,@2x缩放,坐标空间:414 x 896点和828 x 1792像素,326 ppi,设备物理尺寸为 2.98 x 5.94 英寸或 75.7 x 150.9 毫米。6.1 英寸 Liquid 视网膜高清显示屏。

Size for iPhone X Maxwith @3xscaling (Apple name: Super Retina HD 6.5 display"), coordinate space: 414 x 896points and 1242 x 2688pixels, 458 ppi, device physical size is 3.05 x 6.20 in or 77.4 x 157.5 mm.

大小为iPhone X最大值@ 3×缩放(苹果名:超级视网膜HD 6.5显示”),坐标空间:414 X 896点和1242 X 2688个像素,458个PPI,设备的物理尺寸是3.05 X 6.20或77.4 X157.5毫米.

let screen = UIScreen.main
print("Screen bounds: \(screen.bounds), Screen resolution: \(screen.nativeBounds), scale: \(screen.scale)")
//iPhone X Max Screen bounds: (0.0, 0.0, 414.0, 896.0), Screen resolution: (0.0, 0.0, 1242.0, 2688.0), scale: 3.0

Size for iPhone Xwith @2xscaling (Apple name: Super Retina HD 6.1" display), coordinate space: 414 x 896points and 828 x 1792pixels, 326 ppi, device physical size is 2.98 x 5.94 in or 75.7 x 150.9 mm.

大小为iPhone X@ 2X缩放(苹果名:超级视网膜HD 6.1"显示器),坐标空间:414 X 896点和828 X 1792像素,326 PPI,设备的物理尺寸是在2.98 X 5.94或75.7 X150.9毫米。

let screen = UIScreen.main
print("Screen bounds: \(screen.bounds), Screen resolution: \(screen.nativeBounds), scale: \(screen.scale)")
//iPhone X Screen bounds: (0.0, 0.0, 414.0, 896.0), Screen resolution: (0.0, 0.0, 828.0, 1792.0), scale: 2.0

Size for iPhone Xand iPhone Xwith @3xscaling (Apple name: Super Retina HD 5.8" display), coordinate space: 375 x 812points and 1125 x 2436pixels, 458 ppi, device physical size is 2.79 x 5.65 in or 70.9 x 143.6 mm.

尺寸为iPhone XiPhone X@ 3倍缩放(苹果名称:超级视网膜高清5.8"显示屏),坐标空间:375 X 812点和1125 X 2436个像素,458 PPI,设备的物理尺寸为2.79 X 5.65或70.9 X 143.6 毫米。

let screen = UIScreen.main
print("Screen bounds: \(screen.bounds), Screen resolution: \(screen.nativeBounds), scale: \(screen.scale)")
//iPhone X and X Screen bounds: (0.0, 0.0, 375.0, 812.0), Screen resolution: (0.0, 0.0, 1125.0, 2436.0), scale: 3.0

enter image description here

enter image description here

Size for iPhone 6, 6S, 7 and 8with @3xscaling (Apple name: Retina HD 5.5), coordinate space: 414 x 736points and 1242 x 2208pixels, 401 ppi, screen physical size is 2.7 x 4.8 in or 68 x 122 mm. When running in Zoomed Mode, i.e. without the new LaunchImages or choosen in Setup on iPhone 6 Plus, the native scale is 2.88 and the screen is 320 x 568 points, which is the iPhone 5 native size:

iPhone 6、6S、7 和 8尺寸,@3x缩放(Apple 名称:Retina HD 5.5),坐标空间:414 x 736点和1242 x 2208像素,401 ppi,屏幕物理尺寸为 2.7 x 4.8 英寸或68 x 122 毫米。在缩放模式下运行时,即没有新的 LaunchImages 或在 iPhone 6 Plus 上的 Setup 中选择时,原始比例为 2.88,屏幕为 320 x 568 点,这是 iPhone 5 的原始尺寸:

Screen bounds: {{0, 0}, {414, 736}}, Screen resolution: <UIScreen: 0x7f97fad330b0; bounds = {{0, 0}, {414, 736}};
mode = <UIScreenMode: 0x7f97fae1ce00; size = 1242.000000 x 2208.000000>>, scale: 3.000000, nativeScale: 3.000000


Size for iPhone 6and iPhone 6Swith @2x scaling (Apple name: Retina HD 4.7), coordinate space: 375 x 667points and 750 x 1334pixels, 326 ppi, screen physical size is 2.3 x 4.1 in or 58 x 104 mm. When running in Zoomed Mode, i.e. without the new LaunchImages, the screen is 320 x 568 points, which is the iPhone 5 native size:

iPhone 6iPhone 6S尺寸@2x 缩放(Apple 名称:Retina HD 4.7),坐标空间:375 x 667点和750 x 1334像素,326 ppi,屏幕物理尺寸为 2.3 x 4.1 英寸或58 x 104 毫米。在缩放模式下运行时,即没有新的 LaunchImages,屏幕为 320 x 568 点,这是 iPhone 5 的原生尺寸:

Screen bounds: {{0, 0}, {375, 667}}, Screen resolution: <UIScreen: 0x7fa01b5182d0; bounds = {{0, 0}, {375, 667}};
mode = <UIScreenMode: 0x7fa01b711760; size = 750.000000 x 1334.000000>>, scale: 2.000000, nativeScale: 2.000000

And iPhone 5for comparison is 640 x 1136, iPhone 4640 x 960.

iPhone 5的对比是640×1136,iPhone 4的640×960。



Here is the code I used to check this out (note that nativeScale only runs on iOS 8):

这是我用来检查的代码(注意 nativeScale 仅在 iOS 8 上运行):

UIScreen *mainScreen = [UIScreen mainScreen];
NSLog(@"Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f",
          NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);

Note: Upload LaunchImages otherwise the app will run in Zoomed Mode and not show the correct scaling, or screen sizes. In Zoomed Mode the nativeScaleand scalewill not be the same.On an actual device the scale can be 2.608 on the iPhone 6 Plus, even when it is not running in Zoomed Mode, but it will show scale of 3.0 when running on the simulator.

注意:上传 LaunchImages 否则应用程序将在缩放模式下运行并且不会显示正确的缩放比例或屏幕尺寸。在缩放模式下,nativeScalescale将不同。在实际设备上,iPhone 6 Plus 的比例可以是 2.608,即使它没有在缩放模式下运行,但在模拟器上运行时会显示 3.0 的比例。

Comparing iPhone 6 and 6 Plus

Comparing iPhone 6 and 6 Plus

回答by Leszek Szary

Real/physical iPhone 6 Plus resolution is 1920x1080 but in Xcode you make your interface for 2208x1242 resolution (736x414 points) and on device it is automatically scaled down to 1920x1080 pixels.

真实/物理 iPhone 6 Plus 分辨率为 1920x1080,但在 Xcode 中,您将界面设置为 2208x1242 分辨率(736x414 点),并且在设备上它会自动缩小到 1920x1080 像素。

iPhone resolutions quick reference:

iPhone 分辨率快速参考:

Device          Points    Pixels     Scale  Physical Pixels   PPI   Ratio   Size
iPhone XS Max   896x414   2688x1242  3x     2688x1242         458   19.5:9  6.5"
iPhone XR       896x414   1792x828   2x     1792x828          326   19.5:9  6.1"
iPhone X        812x375   2436x1125  3x     2436x1125         458   19.5:9  5.8"
iPhone 6 Plus   736x414   2208x1242  3x     1920x1080         401   16:9    5.5"
iPhone 6        667x375   1334x750   2x     1334x750          326   16:9    4.7"
iPhone 5        568x320   1136x640   2x     1136x640          326   16:9    4.0"
iPhone 4        480x320   960x640    2x     960x640           326   3:2     3.5"
iPhone 3GS      480x320   480x320    1x     480x320           163   3:2     3.5"

iPhone resolutions

iPhone resolutions

回答by davidisdk

You should probably stop using launch images in iOS 8 and use a storyboard or nib/xib.

您可能应该停止在 iOS 8 中使用启动图像并使用故事板或 nib/xib。

  • In Xcode 6, open the Filemenu and choose New? File...? iOS? User Interface? Launch Screen.

  • Then open the settingsfor your project by clicking on it.

  • In the Generaltab, in the section called App Icons and Launch Images, set the Launch Screen Fileto the files you just created (this will set UILaunchStoryboardNamein info.plist).

  • Xcode 6 中,打开File菜单并选择New? File...? iOS? User Interface? Launch Screen.

  • 然后通过单击打开项目的设置

  • General选项卡中,在名为 的部分中App Icons and Launch Images,将 设置为Launch Screen File您刚刚创建的文件(这将UILaunchStoryboardName在 中设置info.plist)。

Note that for the time being the simulator will only show a black screen, so you need to test on a real device.

请注意,模拟器暂时只会显示黑屏,因此您需要在真机上进行测试

Adding a Launch Screen xib file to your project:

将启动屏幕 xib 文件添加到您的项目:

Adding a new Launch Screen xib file

Adding a new Launch Screen xib file

Configuring your project to use the Launch Screen xib file instead of the Asset Catalog:

配置您的项目以使用启动屏幕 xib 文件而不是资产目录:

Configure project to use Launch Screen xob

Configure project to use Launch Screen xob

回答by Jeremy Huddleston Sequoia

On the physical device, iPhone 6 Plus's main screen's bounds is 2208x1242and nativeBounds is 1920x1080. There is hardware scaling involved to resize to the physical display.

在实体设备上,iPhone 6 Plus 的主屏幕边界为2208x1242, nativeBounds 为1920x1080。调整物理显示器的大小需要硬件缩放。

On the simulator, the iPhone 6 Plus's main screen's bounds and nativeBounds are both 2208x1242.

在模拟器上,iPhone 6 Plus 的主屏bounds 和nativeBounds 都是2208x1242。

In other words... Videos, OpenGL, and other things based on CALayersthat deal with pixels will deal with the real 1920x1080frame buffer on device (or 2208x1242on sim). Things dealing with points in UIKitwill be deal with the 2208x1242(x3) bounds and get scaled as appropriate on device.

换句话说......视频、OpenGL 和其他基于CALayers像素处理的东西将处理设备上真实的1920x1080帧缓冲区(或sim上的2208x1242)。处理点的事情UIKit将处理2208x1242(x3) 边界并在设备上适当缩放。

The simulator does not have access to the same hardware that is doing the scaling on device and there's not really much of a benefit to simulating it in software as they'd produce different results than the hardware. Thus it makes sense to set the nativeBoundsof a simulated device's main screen to the bounds of the physical device's main screen.

模拟器无法访问在设备上进行缩放的相同硬件,并且在软件中模拟它并没有太大的好处,因为它们会产生与硬件不同的结果。因此nativeBounds,将模拟设备的主屏幕设置为物理设备主屏幕的边界是有意义的。

iOS 8 added API to UIScreen(nativeScaleand nativeBounds) to let a developer determine the resolution of the CADisplaycorresponding to the UIScreen.

iOS 8 为UIScreen(nativeScalenativeBounds)添加了 API 以让开发人员确定CADisplay对应于UIScreen.

回答by Fran?ois Verry

For those like me who wonder how legacy apps are treated, I did a bit of testing and computation on the subject.

对于像我这样想知道如何处理遗留应用程序的人,我对这个主题进行了一些测试和计算。

Thanks to @hannes-sverrisson hint, I started on the assumption that a legacy app is treated with a 320x568 view in iPhone 6 and iPhone 6 plus.

感谢@hannes-sverrisson 的提示,我开始假设在 iPhone 6 和 iPhone 6 plus 中使用 320x568 视图处理旧应用程序。

The test was made with a simple black background [email protected]with a white border. The background has a size of 640x1136 pixels, and it is black with an inner white border of 1 pixel.

测试是在带有[email protected]白色边框的简单黑色背景下进行的。背景大小为 640x1136 像素,为黑色,内部白色边框为 1 像素。

Below are the screenshots provided by the simulator:

下面是模拟器提供的截图:

On the iPhone 6 screenshot, we can see a 1 pixel margin on top and bottom of the white border, and a 2 pixel margin on the iPhone 6 plus screenshot. This gives us a usedspace of 1242x2204 on iPhone 6 plus, instead of 1242x2208, and 750x1332 on the iPhone 6, instead of 750x1334.

在 iPhone 6 截图上,我们可以看到白色边框上下边距为 1 像素,iPhone 6 plus 截图为 2 像素边距。这为我们提供了iPhone 6 plus 上 1242x2204的已空间,而不是 1242x2208,iPhone 6 上的已空间为 750x1332,而不是 750x1334。

We can assume that those dead pixels are meant to respect the iPhone 5 aspect ratio:

我们可以假设这些坏点是为了尊重 iPhone 5 的纵横比:

iPhone 5               640 / 1136 = 0.5634
iPhone 6 (used)        750 / 1332 = 0.5631
iPhone 6 (real)        750 / 1334 = 0.5622
iPhone 6 plus (used)  1242 / 2204 = 0.5635
iPhone 6 plus (real)  1242 / 2208 = 0.5625

Second, it is important to know that @2x resources will be scaled not only on iPhone 6 plus (which expects @3x assets), but also on iPhone 6. This is probably because not scaling the resources would have led to unexpected layouts, due to the enlargement of the view.

其次,重要的是要知道 @2x 资源不仅会在 iPhone 6 plus(期望 @3x 资产)上缩放,而且还会在 iPhone 6 上缩放。这可能是因为不缩放资源会导致意外布局,由于到视图的放大。

However, that scaling is not equivalent in width and height. I tried it with a 264x264 @2x resource. Given the results, I have to assume that the scaling is directly proportional to the pixels / points ratio.

但是,该缩放比例在宽度和高度上并不相同。我使用 264x264 @2x 资源进行了尝试。鉴于结果,我必须假设缩放比例与像素/点比成正比。

Device         Width scale             Computed width   Screenshot width
iPhone 5        640 /  640 = 1.0                        264 px
iPhone 6        750 /  640 = 1.171875  309.375          309 px
iPhone 6 plus  1242 /  640 = 1.940625  512.325          512 px

Device         Height scale            Computed height  Screenshot height
iPhone 5       1136 / 1136 = 1.0                        264 px
iPhone 6       1332 / 1136 = 1.172535  309.549          310 px
iPhone 6 plus  2204 / 1136 = 1.940141  512.197          512 px

It's important to note the iPhone 6 scaling is not the same in width and height(309x310). This tends to confirm the above theory that scaling is not proportional in width and height, but uses the pixels / points ratio.

重要的是要注意 iPhone 6 的宽度和高度(309x310)缩放比例不同。这往往证实了上述缩放比例与宽度和高度不成正比,而是使用像素/点比率的理论。

I hope this helps.

我希望这有帮助。

回答by Darrarski

Check out this infographic: http://www.paintcodeapp.com/news/iphone-6-screens-demystified

查看此信息图:http: //www.paintcodeapp.com/news/iphone-6-screens-demystified

It explains the differences between old iPhones, iPhone 6 and iPhone 6 Plus. You can see comparison of screen sizes in points, rendered pixels and physical pixels. You will also find answer to your question there:

它解释了旧 iPhone、iPhone 6 和 iPhone 6 Plus 之间的区别。您可以查看以点、渲染像素和物理像素为单位的屏幕尺寸比较。您还可以在那里找到问题的答案:

iPhone 6 Plus - with Retina display HD. Scaling factor is 3 and the image is afterwards downscaled from rendered 2208 × 1242 pixels to 1920 × 1080 pixels.

The downscaling ratio is 1920 / 2208 = 1080 / 1242 = 20 / 23. That means every 23 pixels from the original render have to be mapped to 20 physical pixels. In other words the image is scaled down to approximately 87% of its original size.

iPhone 6 Plus - 配备 Retina 高清显示屏。缩放因子为 3,然后将图像从渲染的 2208 × 1242 像素缩小到 1920 × 1080 像素。

缩小比例为 1920 / 2208 = 1080 / 1242 = 20 / 23。这意味着原始渲染中的每 23 个像素必须映射到 20 个物理像素。换句话说,图像被缩小到其原始尺寸的大约 87%。

Update:

更新:

There is an updated version of infographic mentioned above. It contains more detailed info about screen resolution differences and it covers all iPhone models so far, including 4 inch devices.

上面提到的信息图有一个更新版本。它包含有关屏幕分辨率差异的更多详细信息,并且涵盖了迄今为止的所有 iPhone 型号,包括 4 英寸设备。

http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

回答by rawpower

Even if I don't generally like the tone of John Gruber's Daring Fireball blog, his Larger iPhone Display Conjectureis well worth the read.

即使我通常不喜欢 John Gruber 的 Daring Fireball 博客的语气,他的大 iPhone 显示器猜想也非常值得一读。

He guessed but got exactlyright both the resolution in points and in pixels for both models, except that he did not (me neither) expect Apple to build a smaller resolution physical display and scale down (details are in @Tommy's answer).

他猜测但两种模型的分辨率都以点数和像素为单位完全正确,只是他(我也不)期望 Apple 构建分辨率更小的物理显示器并按比例缩小(详细信息在@Tommy 的回答中)。

The gist of it all is that one should stop thinking in terms of pixels and start thinking in terms of points (this has been the case for quite some time, it's not a recent invention) and resulting physical size of UI elements. In short, both new iPhone models improve in this regard as physically most elements remain the same size, you can just fit more of them on the screen (for each bigger screen you can fit more).

这一切的要点是,人们应该停止考虑像素,而应该开始考虑点(这种情况已经存在很长一段时间了,这不是最近的发明)以及由此产生的 UI 元素的物理尺寸。简而言之,两款新 iPhone 机型在这方面都有所改进,因为大多数元素的物理尺寸保持不变,您可以在屏幕上放置更多的元素(对于每个更大的屏幕,您可以放置​​更多)。

I'm just slightly disappointed they haven't kept mapping of internal resolution to actual screen resolution 1:1 for the bigger model.

我只是有点失望,他们没有将内部分辨率映射到更大型号的实际屏幕分辨率 1:1。