第一种
CGRect screen = [[UIScreenmainScreen] applicationFrame];
//app尺寸,去掉状态栏
这个尺寸不会随着屏幕旋转而交换宽高,但屏幕旋转后,会自动修改宽高减掉状态栏高度
*---------------------------------------------------------------*
NSLog(@"x:%f, y:%f,width:%f,hight:%f",
[[UIScreenmainScreen] applicationFrame]. origin.x,
[[UIScreenmainScreen] applicationFrame].origin.y,
[[UIScreenmainScreen] applicationFrame].size.width,
[[UIScreenmainScreen] applicationFrame].size.height);
打印结果:
//竖屏时(4寸):x=0, y=20, width=320, height=548
//横屏时(4寸):x=20,y=0, width=300, height=568
第二种
CGRect screen = [[UIScreen mainScreen] bounds];
//(4寸)rx=x=0, y=0, width=320, height=568
//尺寸固定,不随屏幕旋转变化