UIScreen边界与applicationFrame [英] UIScreen bounds versus applicationFrame

查看:91
本文介绍了UIScreen边界与applicationFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我在Apple的一些示例代码(如PhotoScroller)中看到,我应该在 loadView 中执行以下操作:

Why do I see in some sample code from Apple (such as PhotoScroller) that I should do the following in loadView:

CGRect frame = [[UIScreen mainScreen] bounds]; 

而不是

CGRect frame = [[UIScreen mainScreen] applicationFrame]; 

获得主屏幕框架会有所不同吗?

Does it make a difference to get the main screen's frame?

推荐答案

ApplicationFrame是屏幕大小减去状态栏的大小(如果可见),bounds是屏幕大小bar。

ApplicationFrame is the screen size minus the size of the status bar (if visible), bounds is the screen size regardless of status bar.

所以applicationFrame会返回 CGRectMake(0,0,320,460),假设你的应用程序的状态栏设置为可见,而边界将在相同的条件下返回 CGRectMake(0,0,320,480)。这些数字是假设iPhone / iPod Touch屏幕尺寸。

So applicationFrame would return CGRectMake(0,0,320,460) assuming your app has the status bar set to be visible, while bounds would return CGRectMake(0,0,320,480) under the same conditions. Those numbers are assuming iPhone/iPod Touch screen sizes.

UIScreen类参考

这篇关于UIScreen边界与applicationFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆