UINavigationBar框架高度返回44.0,但实际上是64.0 [英] UINavigationBar frame height returns 44.0 but is actually 64.0
问题描述
我在情节提要中有一个不使用AutoLayout的UINavigationController.在状态栏可见的情况下,UINavigationBar的实际高度为64.0,但是当我登录 self.navigationBar.frame.size.height
时,我的高度为44.0.如何获取UINavigationBar的实际高度?
I have a UINavigationController in a storyboard which is not using AutoLayout. With the status bar visible the actual height of the UINavigationBar is 64.0 and yet when I log self.navigationBar.frame.size.height
I get 44.0. How do I get the actual height of the UINavigationBar?
我正在使用Xcode 7.3,并且故事板是为iOS 6构建的.
I'm using Xcode 7.3 and the storyboard builds for iOS 6.
推荐答案
UINavigationBar
的高度为 44 .您获得 64 的原因是因为状态栏可见,并且高度为 20 .
The height of the UINavigationBar
is 44. The reason you´re getting 64 is because of your status bar is visible and it has a height of 20.
更新:
要计算高度,您可以:
Update:
To calculate the height you could:
let height = Double(UIApplication.shared.statusBarFrame.height) + Double(self.navigationController!.navigationBar.frame.height)
这篇关于UINavigationBar框架高度返回44.0,但实际上是64.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!