iOS適配機型常用巨集以及機型尺寸備註

2022-05-27 17:03:13 字數 3446 閱讀 5531

關於物理和邏輯解析度再整理一下,雖然並不關心太多的硬體原理,但是還是留個地方方便查閱吧。

1、**

#pragma mark - 判斷機型

/*裝置是否為iphone4、iphone4s

(1)邏輯解析度(point):320x480

(2)物理解析度(pixel,畫素):640x1136

(3)縮放因子 :@2x

(4)ppi(畫素密度): 326

(5)對角線:3.5 inch */

#define iphone4 ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? cgsizeequaltosize(cgsizemake(640,960), [[uiscreen mainscreen] currentmode].size) : no)

/*裝置是否為iphone5、iphonec5c、iphone5s

(1)邏輯解析度(point):320x568

(2)物理解析度(pixel,畫素):640x1136

(3)縮放因子 :@2x

(4)ppi(畫素密度): 326

(5)對角線:4 inch */

#define iphone5 ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? cgsizeequaltosize(cgsizemake(640, 1136), [[uiscreen mainscreen] currentmode].size) : no)

/*裝置是否為iphone6、iphone7、iphone8

(1)邏輯解析度(point):375x667

(2)物理解析度(pixel,畫素):750x1334

(3)縮放因子 :@2x

(4)ppi(畫素密度): 326

(5)對角線:4.7 inch

*/#define iphone6 ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? cgsizeequaltosize(cgsizemake(750, 1334), [[uiscreen mainscreen] currentmode].size) : no)

/*裝置是否為iphone6plus 、iphone7plus、iphone8plus

(1)邏輯解析度(point):414x736

(2)物理解析度(pixel,畫素):1242x2208,但是實際為1080*1920,顯示前做縮放

(3)縮放因子 :@3x

(4)ppi(畫素密度): 401

(5)對角線:5.5 inch */

#define iphone6p ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? (cgsizeequaltosize(cgsizeequaltosize(cgsizemake(1242,2208), [[uiscreen mainscreen] currentmode].size)) : no)

/*裝置是否為iphonex、iphonexs

(1)邏輯解析度(point):375*812

(2)物理解析度(pixel,畫素):1125x2436

(3)縮放因子 :@3x

(4)ppi(畫素密度): 458

(5)對角線:5.8 inch */

#define iphonex ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? cgsizeequaltosize(cgsizemake(1125,2436), [[uiscreen mainscreen] currentmode].size) : no)

/*裝置是否為判斷iphonexr

(1)邏輯解析度(point):414*896

(2)物理解析度(pixel,畫素):828x1792

(3)縮放因子 :@2x

(4)ppi(畫素密度): 326

(5)對角線:6.1 inch */

#define iphonexr ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? cgsizeequaltosize(cgsizemake(828,1792), [[uiscreen mainscreen] currentmode].size) : no)

/*裝置是否為判斷iphonexs max

(1)邏輯解析度(point):414*896

(2)物理解析度(pixel,畫素):1242*2688

(3)縮放因子 :@3x

(4)ppi(畫素密度): 458

(5)對角線:6.5 inch */

#define iphonexs_max ([uiscreen instancesrespondtoselector:@selector(currentmode)] ? cgsizeequaltosize(cgsizemake(1242,2688), [[uiscreen mainscreen] currentmode].size) : no)

2、列表

3、所有機型引數

4、一些名詞解釋

(1)ppi 畫素密度

表示沿著對角線,每英吋所擁有的畫素(pixel)數目,ppi的數值越高,代表顯示屏能夠以越高的密度顯示影象,即通常所說的解析度越高,顆粒感越弱,影象更清晰。

舉例: 根據勾股定理:iphone4/iphone4s的ppi的計算值:

(2)縮放因子

(3)物理解析度和邏輯解析度

5、關於iphone6plus的物理解析度的問題

iphone6plus的實際物理畫素是標準的1080x1920,但是渲染解析度是1242x2208,目前就是iphone6plus、iphone7plus、iphone8plus有這個特殊情況。

(1)系統中獲取的是1242x2208物理解析度

(2)截圖出來看到的也是1242x2208的解析度

(3)縮放比是3,邏輯解析度是414x736,對應的物理解析度就是 1242 x2208。。同時, 對應到物理螢幕上「真實」的1080x1920,需要進行縮放處理。

(4) 為什麼不直接使用1242x2208的物理解析度,或者說,在縮放比為3的情況下,為什麼邏輯解析度是414x736?(為什麼不降低邏輯解析度,拿1080➗3來算?)

下面是網上的一些分析:

ios版本適配,機型適配,橫豎屏適配

1,版本適配 ios系統的判定,這個可以通過 uidevice currentdevice systemversion floatvalue 來獲得當前的系統版本。2,機型適配 螢幕尺寸 define device is iphone4s uiscreenmainscreen bounds size...

iOS UI定位布局適配機型尺寸

給控制項加frame的時候,我們最開始使用的是cgrectmake,但是單純的cgrectmake不能滿足所有寬高比例的螢幕,不能很好的做適配。下面介紹cgrectmake的改良方法 可以適配絕大部分尺寸和機型的絕大部分的控制項 pragma mark 螢幕適配 cg inline cgrect m...

html5 適配機型 rem方案

rem rem font size of the root element 是指相對於根元素的字型大小的單位。簡單的說它就是乙個相對單位。html 以上 等同於 1em 16px 比如設定文字大小為 font size 1rem 當html 和html 同樣設定font size 1rem 字型的大...