How to get the Navigation Bar height in iOS?


A navigation bar appears at the top of an app screen. To read more about it

https://developer.apple.com/design

https://developer.apple.com/documentation

Getting height of Navigation bar becomes important if you’ve multiple view controllers having different UI and requirement. It becomes hectic if you’re not aware how to get the height of the same or modify as per need. Let’s see how we can get the height of Navigation bar.

import UIKit
class ViewController: UIViewController {
   override func viewDidLoad() {
      super.viewDidLoad()
      let navBarHeight = UIApplication.shared.statusBarFrame.size.height +
         (navigationController?.navigationBar.frame.height ?? 0.0)
      print(navBarHeight)
   }
}
raja
Published on 08-Jul-2019 07:49:03
Advertisements