码迷,mamicode.com
首页 > 移动开发 > 详细

ios设备的尺寸不大敏感[UIScreen mainScreen

时间:2015-03-09 16:01:27      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

一直对ios设备的尺寸不大敏感,搞不清[[UIScreen mainScreen] bounds] 和[UIScreen mainScreen] applicationFrame]的区别,故总是心虚,现扫盲下:

定义一个宏:

1
#define PrintRect(frame) NSLog(@"X:%f,Y:%f,W:%f,H:%f",frame.origin.x,frame.origin.y,frame.size.width,frame.size.height)

 

测试调用:

1
2
3
4
5
NSLog(@"[[UIScreen mainScreen] bounds]");
 PrintRect([[UIScreen mainScreen] bounds]);
     
 NSLog(@"[[UIScreen mainScreen] applicationFrame]");
 PrintRect([[UIScreen mainScreen]applicationFrame]);

 

测试结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//Ipad4 retain:
2013-07-17 10:08:39.094 IpadSize[191:907] [[UIScreen mainScreen] bounds]
2013-07-17 10:08:39.097 IpadSize[191:907] X:0.000000,Y:0.000000,W:768.000000,H:1024.000000
 
2013-07-17 10:08:39.098 IpadSize[191:907] [[UIScreen mainScreen] applicationFrame]
2013-07-17 10:08:39.099 IpadSize[191:907] X:0.000000,Y:20.000000,W:768.000000,H:1004.000000
 
//ipad normal:
2013-07-17 10:19:09.886 IpadSize[1223:11303] [[UIScreen mainScreen] bounds]
2013-07-17 10:19:09.887 IpadSize[1223:11303] X:0.000000,Y:0.000000,W:768.000000,H:1024.000000
2013-07-17 10:19:09.887 IpadSize[1223:11303] [[UIScreen mainScreen] applicationFrame]
2013-07-17 10:19:09.888 IpadSize[1223:11303] X:0.000000,Y:20.000000,W:768.000000,H:1004.000000
 
//iphone:
2013-07-17 10:15:39.372 IpadSize[1005:11303] [[UIScreen mainScreen] bounds]
2013-07-17 10:15:39.373 IpadSize[1005:11303] X:0.000000,Y:0.000000,W:320.000000,H:480.000000
2013-07-17 10:15:39.374 IpadSize[1005:11303] [[UIScreen mainScreen] applicationFrame]
2013-07-17 10:15:39.374 IpadSize[1005:11303] X:0.000000,Y:20.000000,W:320.000000,H:460.000000
 
 
 
//iphone 3.5 retain:
2013-07-17 10:16:34.145 IpadSize[1043:11303] [[UIScreen mainScreen] bounds]
2013-07-17 10:16:34.146 IpadSize[1043:11303] X:0.000000,Y:0.000000,W:320.000000,H:480.000000
2013-07-17 10:16:34.147 IpadSize[1043:11303] [[UIScreen mainScreen] applicationFrame]
2013-07-17 10:16:34.147 IpadSize[1043:11303] X:0.000000,Y:20.000000,W:320.000000,H:460.000000
 
//iphone 4 retain:
2013-07-17 10:17:26.562 IpadSize[1083:11303] [[UIScreen mainScreen] bounds]
2013-07-17 10:17:26.563 IpadSize[1083:11303] X:0.000000,Y:0.000000,W:320.000000,H:568.000000
2013-07-17 10:17:26.564 IpadSize[1083:11303] [[UIScreen mainScreen] applicationFrame]
2013-07-17 10:17:26.564 IpadSize[1083:11303] X:0.000000,Y:20.000000,W:320.000000,H:548.000000
 
//IPHONE 6 Plus:
2015-01-09 19:59:57.905 TripPlusMeIphone[1183:230595] [[UIScreen mainScreen] bounds]
2015-01-09 19:59:57.905 TripPlusMeIphone[1183:230595] X:0.000000,Y:0.000000,W:414.000000,H:736.000000
2015-01-09 19:59:57.905 TripPlusMeIphone[1183:230595] [[UIScreen mainScreen] applicationFrame]
2015-01-09 19:59:57.905 TripPlusMeIphone[1183:230595] X:0.000000,Y:0.000000,W:414.000000,H:736.000000
 
//iphone 6
2015-01-09 20:02:32.910 TripPlusMeIphone[87512:1855595] [[UIScreen mainScreen] bounds]
2015-01-09 20:02:32.911 TripPlusMeIphone[87512:1855595] X:0.000000,Y:0.000000,W:375.000000,H:667.000000
2015-01-09 20:02:32.911 TripPlusMeIphone[87512:1855595] [[UIScreen mainScreen] applicationFrame]
2015-01-09 20:02:32.911 TripPlusMeIphone[87512:1855595] X:0.000000,Y:0.000000,W:375.000000,H:667.000000

 

从日志输出可以看到,bounds就是屏幕的全部区域,applicationFrame就是app显示的区域,不包含状态栏(高度20,如果状态栏隐藏的话,那么,这个结果就和bounds一样了)

ios设备的尺寸不大敏感[UIScreen mainScreen

标签:

原文地址:http://www.cnblogs.com/shupaopao/p/4323541.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!