天天看點

最新的iPhone 各種機型尺寸資訊清單(含iPhone 7/8、iPhoneX、iPhone XR、iPhone XS Max)

1. iPhone 各種機型尺寸資訊清單入下表:

機型 尺寸

邏輯縮放因子

(UIKit Scale factor)

實際縮放因子

(Native Scale factor)

螢幕寬高 螢幕分辨率
3GS 3.5寸 1.0 1.0 320x480 320x480
4(S) 3.5寸 2.0 2.0 320x480 640x960
5(C)/5(S)/SE 4寸 2.0 2.0 320x568 640x1136
6(S)/7/8 4.7寸 2.0 2.0 375x667 750x1334
6(S)+/7+/8+ 5.5寸 3.0 2.608 414x736 1080x1920
X/XS 5.8寸 3.0 3.0 375x812 1125x2436
XR 6.1寸 2.0 2.0 414×896 828 x1792
XS Max 6.5寸 3.0 3.0 414×896 1242x2688

需要注意的地方是,6(S)+/7+/8+的時候,實際的縮放因子并不等于邏輯上的縮放因子。是以,他的螢幕分辨率是1080x1920而不是1242x2208。

上述資料,可以通過代碼獲得。擷取邏輯縮放因子、邏輯螢幕寬度;實際縮放/實體因子、實際/實體螢幕寬度的方式:

//邏輯縮放因子
[UIScreen mainScreen].scale

//邏輯螢幕寬度
[UIScreen mainScreen].bounds


//實際/實體縮放因子
[UIScreen mainScreen].nativeScale

//實際/實體螢幕寬度
[UIScreen mainScreen].nativeBounds
           

        iOS裡面對于縮放因子有2個不同的概念。一個是其實際的縮放因子(Native Scale factor),一個是UIKit上所表示的邏輯縮放因子(UIKit Scale factor)。當UIKit Scale factor和Native Scale factor不相等的時候,系統會先使用邏輯上的factor(即UIKit Scale factor)來渲染,渲染之後再把結果進行縮放,使之符合Native Scale factor下渲染的樣子。在一些UI渲染計算量大的應用(如遊戲),這類多餘的渲染是很耗費資源的,應該在渲染這類UI的時候指定使用Native Scale factor來做渲染。MetalKit(新的系統接口,支援GPU加速3D繪圖的API。)裡面有這個用法。詳情見官網。

參考:《為什麼 iPhone 6 Plus 要将 3x 渲染的 2208x1242 分辨率縮小到 1080p 螢幕上?》

2. 手機機型區分

       由于現在iPhone 6、iPhone 7、iPhone 8螢幕尺寸一樣,他們的Plus版也是一樣的。是以按照以前的以螢幕高度來區分的方法,結果會有可能重疊。

      (1)以螢幕高度的不同來區分

#define iPhone_4 ((int)[UIScreen mainScreen].bounds.size.height == 480)

#define iPhone_5 ((int)[UIScreen mainScreen].bounds.size.height == 568)

#define iPhone_6 ((int)[UIScreen mainScreen].bounds.size.height == 667) //6、7、8

#define iPhone_6p ((int)[UIScreen mainScreen].bounds.size.height ==736)//6p、7p、8p

#define iPhone_X  ((int)[UIScreen mainScreen].bounds.size.height ==812)