獲取屏幕尺寸
1.根據像素
UIScreenMode *ScreenMode = [[UIScreen mainScreen] currentMode];
float width = ScreenMode.size.width;
float height = ScreenMode.size.height;
以上代碼在不同設備上,得到的值是不同的。
注意:這種方式獲得的值是以像素爲單位的(The width and height in pixels)。
不同設備上的值爲:
iPhone (3.5 inch): 320 x 480iPhone Retina (3.5 inch): 640 x 960
iPhone Retina (4.0 inch): 640 x 1136
iPad: 768 x 1024
iPad Retina: 1536 x 2048
2.根據點
CGRect bounds = [[UIScreen mainScreen] bounds];
float width = bounds.size.width;
float height = bounds.size.height;
不同設備上的值爲:
iPhone (3.5 inch): 320 x 480iPhone Retina (3.5 inch): 320 x 480
iPhone Retina (4.0 inch):320 x 568
iPad: 320 x 480
iPad Retina: 320 x 480
/***************************************************/