搞不清[[UIScreen mainScreen] bounds] 和[UIScreen mainScreen] applicationFrame]的区别,现扫盲下:
定义一个宏:
define PrintRect(frame) NSLog(@”—>X:%f,Y:%f,W:%f,H:%f”,frame.origin.x,frame.origin.y,frame.size.width,frame.size.height)
//iphone 3.5 retain:
—>X:0.000000,Y:0.000000,W:320.000000,H:480.000000
—>X:0.000000,Y:20.000000,W:320.000000,H:460.000000
//iphone 4 retain:
—>X:0.000000,Y:0.000000,W:320.000000,H:568.000000
—>X:0.000000,Y:20.000000,W:320.000000,H:548.000000
//IPHONE 6 Plus:
—>X:0.000000,Y:0.000000,W:414.000000,H:736.000000
—>X:0.000000,Y:0.000000,W:414.000000,H:736.000000
//iphone 6
—>X:0.000000,Y:0.000000,W:375.000000,H:667.000000
—>X:0.000000,Y:0.000000,W:375.000000,H:667.000000
从日志输出可以看到,bounds就是屏幕的全部区域,applicationFrame就是app显示的区域,不包含状态栏(高度20,如果状态栏隐藏的话,那么,这个结果就和bounds一样了)