UINavigationBar frame height returns 44.0 but is actually 64.0

3 Solutions Collect From Internet About “UINavigationBar frame height returns 44.0 but is actually 64.0”

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)

Do not use magic numbers. Use the view controller’s topLayoutGuide.length to get the correct height. Navigation bar height and status bar height can change during runtime, so run your code in viewDidLayoutSubviews to always use the correct value.

The cleanest way is to just care of the navigationBar position and height and not assume there is a status bar over it. (As a matter of fact if the phone orientation is landscape there won’t even be a status bar.
Just do this:

let height = Double(self.navigationController!.navigationBar.origin.y) + Double(self.navigationController!.navigationBar.frame.height)