我想获取状态栏的高度。这个我平时用的
[UIApplication sharedApplication].statusBarFrame.size.height
但是当我在模拟器中按下 Cmd + Y 时,会出现调用状态栏并且我的 View Controller 会向下移动。
有没有类似top的函数获取这个调用状态栏的高度?
谢谢
最佳答案
根据 Apple 文档:
UIApplicationWillChangeStatusBarFrameNotification
Posted when the app is about to change the frame of the status bar. The
userInfo
dictionary contains anNSValue
object that encapsulates aCGRect
structure expressing the location and size of the new status bar frame. UseUIApplicationStatusBarFrameUserInfoKey
to access this value.
访问状态栏新框架的CGRect后,可以计算出“调用状态栏”的高度等于{frame of status bar}.origin.y
。
关于ios - 带有来电通知的状态栏高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21479564/