我为什么在Apple的一些示例代码(例如PhotoScroller)中看到应该在loadView
中执行以下操作:
CGRect frame = [[UIScreen mainScreen] bounds];
相比之下
CGRect frame = [[UIScreen mainScreen] applicationFrame];
获取主屏幕的框架是否有区别?
我为什么在Apple的一些示例代码(例如PhotoScroller)中看到应该在loadView
中执行以下操作:
CGRect frame = [[UIScreen mainScreen] bounds];
相比之下
CGRect frame = [[UIScreen mainScreen] applicationFrame];
获取主屏幕的框架是否有区别?
ApplicationFrame 是屏幕大小减去状态栏的大小(如果可见),bounds 则是屏幕大小而不考虑状态栏。
因此,假设您的应用程序将状态栏设置为可见,则 applicationFrame 将返回CGRectMake(0,0,320,460)
,而在相同条件下 bounds 将返回CGRectMake(0,0,320,480)
。这些数字基于 iPhone/iPod Touch 屏幕尺寸。
iOS 9更新
在iPad上使用分屏功能时,applicationFrame
返回的是应用窗口的大小。bounds
始终返回设备的大小。
-applicationFrame
在iOS 9中已经被弃用。 - jscs