UIScreen學習記錄

2021-06-25 12:39:49 字數 1294 閱讀 8859

auiscreen

uiscreen物件包含了整個螢幕的邊界矩形。當構造應用的使用者介面介面時,你應該使用該物件的屬性來獲得推薦的矩形大小,用以構造你的程式視窗。

以下列出的屬性和操作是我用過的。

returns the screen object representing the device』s screen.

property    

contains the bounding rectangle of the screen, measured in points. (read-only)

property  

property   

the natural scale factor associated with the screen. (read-only)

[plain]view plain

copy

cgrect bound = [[uiscreen mainscreen] bounds];  // 返回的是帶有狀態列的rect  

float scale = [[uiscreenmainscreen] scale]; // 得到裝置的自然解析度  

對於scale屬性需要做進一步的說明:

retina

的顯示技術,iphone 4採用了960x640畫素解析度的顯示螢幕。由於螢幕大小沒有變,還是3.5英吋,解析度的提公升將iphone 4的顯示解析度提公升至iphone 3gs的四倍,每英吋的面積裡有326個

畫素。scale屬性的值有兩個:

scale = 1; 的時候是代表當前裝置是320*480的解析度(就是iphone4之前的裝置)

scale = 2; 的時候是代表解析度為640*960的解析度

判斷螢幕型別:

[plain]view plain

copy

// 判斷螢幕型別,普通還是視網膜  

float scale = [[uiscreen mainscreen] scale];  

if (scale == 1) else if (scale == 2) else  

對dpi和ppi的理解:

dpi是每英吋的

點數,可以簡單理解為點的密度。

ppi是每英吋的畫素數,可以簡單理解為畫素密度。

點和畫素有區別嗎?很多時候,乙個點 = 乙個畫素。但是,並不盡然,如iphone的視網膜螢幕,它乙個點包含了四個畫素,大大提高了顯示清晰度。

mysql學習記錄 MySQL學習記錄 2

in 子查詢 select from student where id in 1,2 not in 不在其中 select from student where id not in 1,2 is null 是空 select from student where age is null is not...

java學習記錄

陣列雖然是引用資料型別,但它不是類 所以數字中沒有length 方法 只有length屬性。string型別 是乙個類 jdk中已經封裝好的類,是個final類,你可以去查api 類就有屬性和方法但是 string類中沒有length屬性,只有length 方法 1。陣列雖然是引用資料型別,但它不是...

Linux 學習記錄

1.linux 拷貝隱藏檔案 進入當前需要拷貝的目錄,即源目錄 假如 source 拷貝到 centos5.3 cd source tar cf cd centos5.3 tar xvf 或者 cp r centos5.3 2.linux 下新增postgresql 使用者 進入 postgresq...