iphone6 plus 为何打印出的宽度是375

首先看一张比较简单明了的 iPhone 6 与 iPhone 6 Plus 对比图,来自 PaintCode 的《The Ultimate Guide To iPhone Resolutions》:bash

iPhone_6_and_6P_screen_size

 

iPhone 6 Plus 要比 iPhone 6 的屏幕宽 39 Point,分辨率更是高出很多,由于 iPhone 6 Plus 是按 3x 来渲染的,也就是说 1point=3pixes。用如下代码测试:app

?
1
2
3
4
5
UIScreen *mainScreen = [UIScreen mainScreen];
     
     // 须要注意 coordinateSpace 属性 iOS 8 以上才支持
     NSLog(@ "Screen bounds: %@, Screen resolution: %@, scale: %f, nativeScale: %f" ,
           NSStringFromCGRect(mainScreen.bounds), mainScreen.coordinateSpace, mainScreen.scale, mainScreen.nativeScale);

用 iPhone 6 Plus 测试输出结果为:iphone

?
1
Screen bounds: {{0, 0}, {375, 667}}, Screen resolution: <UIScreen: 0x14f601fe0; bounds = {{0, 0}, {375, 667}}; mode = <UIScreenMode: 0x1780321c0; size = 1125.000000 x 2001.000000>>, scale: 3.000000, nativeScale: 2.880000

为何宽度只是375而不是414呢

从上面的图片看知道它们有一个所谓的”Display Zoom”缩放模式,但不知道如何启用此模式。最初觉得是在设置->通用->辅助功能里能够调整,只有一个缩放和更大字体之类的比较接近,但都不是。今天在显示与亮度中终于找到答案了,以下图:ide

 

设置为标准,再运行结果就正常啦:测试

?
1
Screen bounds: {{0, 0}, {414, 736}}, Screen resolution: <UIScreen: 0x146603a60; bounds = {{0, 0}, {414, 736}}; mode = <UIScreenMode: 0x178032da0; size = 1242.000000 x 2208.000000>>, scale: 3.000000, nativeScale: 2.608696

从输出数据中能够看出,即便 6 Plus 缩放到375模式,它加载的依然是三倍的图片资源。另一点,标准模式下 6 Plus 才支持横屏模式,包括主屏幕。字体

文章出处:http://magicalboy.com/iphone-6-plus-screen-width-414-or-375/ui

图片出处:http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutionsspa

相关文章
相关标签/搜索