Can some one tell me how to change the navigation bar height?
Here is what i have so far:
CGFloat navBarHeight = 10;
self.navigationController.navi
Creating category and overriding sizeThatFits(_ size: CGSize) -> CGSize method changes UINavigationBar size all over the app. Assuming you want to change UINavigationBar height/size only in one particular ViewController (in my case)
This is how I did it.
extension UINavigationBar {
open override func sizeThatFits(_ size: CGSize) -> CGSize {
let v = self.value(forKey: "frame") as? CGRect
return v?.size ?? CGSize(width: UIScreen.main.bounds.width, height: 44)
}
}
in caller ViewController would look like
override func viewDidLoad() {
super.viewDidLoad()
configureNavigationBar()
}
private func configureNavigationBar() {
var naviBarFrame = self.navigationController?.navigationBar.frame
naviBarFrame?.size.height = 74
let rect = naviBarFrame ?? CGRect(x: 0, y: 20, width: UIScreen.main.bounds.width, height: 74)
self.navigationController?.navigationBar.setValue(rect, forKey: "frame")
}