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

2021-08-22 13:14:14 字數 733 閱讀 3262

給控制項加frame的時候,我們最開始使用的是cgrectmake,但是單純的cgrectmake不能滿足所有寬高比例的螢幕,不能很好的做適配。

下面介紹cgrectmake的改良方法(可以適配絕大部分尺寸和機型的絕大部分的控制項)

#pragma mark -------螢幕適配-------

cg_inline cgrect

mycgrectmake(cgfloat x, cgfloat y, cgfloat width, cgfloat height)

else

if (screenwidth ==320 && screenheight==568) else

if(screenwidth ==375 && screenheight==667)else

if(screenwidth ==414 && screenheight==736)

rect.origin

.x = x * autosizescalex * 0.5;

rect.origin

.y = y * autosizescaley * 0.5;

rect.size

.width = width * autosizescalex * 0.5;

rect.size

.height = height * autosizescaley * 0.5;

return rect;

}

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

關於物理和邏輯解析度再整理一下,雖然並不關心太多的硬體原理,但是還是留個地方方便查閱吧。1 pragma mark 判斷機型 裝置是否為iphone4 iphone4s 1 邏輯解析度 point 320x480 2 物理解析度 pixel,畫素 640x1136 3 縮放因子 2x 4 ppi 畫...

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

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

html5 適配機型 rem方案

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