转载:iPhone 6 Plus 屏幕宽度问题 375 vs 414

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

iPhone_6_and_6P_screen_size

 

iPhone 6 Plus 要比 iPhone 6 的屏幕宽 39 Point,分辨率更是高出不少,因为 iPhone 6 Plus 是按 3x 来渲染的,也就是说 1point=3pixes。用以下代码测试:

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 测试输出结果为:

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”缩放模式,但不知道如何启用此模式。最初以为是在设置->通用->辅助功能里可以调整,只有一个缩放和更大字体之类的比较接近,但都不是。今天在显示与亮度中终于找到答案了,如下图:

 

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

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 才支持横屏模式,包括主屏幕。

 

6+的放大模式就是用6的分辨率
6的放大模式就是用5的分辨率

 

posted @ 2015-08-24 22:24  爱生活爱代码  阅读(1177)  评论(0编辑  收藏  举报