matteok matteok - 11 months ago 70
iOS Question

UINavigationBar frame.height returns 44.0 but is actually 64.0

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?

I'm using Xcode 7.3 and the storyboard builds for iOS 6.

Answer Source

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.

To calculate the height you could:

let height = Double(UIApplication.shared.statusBarFrame.height) + Double(self.navigationController!.navigationBar.frame.height)