Is there a way to change (namely, decrease) the height of a UINavigationBar in a UINavigationController? I have tried the following to no avail:
extension UINavigationBar {
override open func sizeThatFits(_ size: CGSize) -> CGSize {
return CGSize(width: UIScreen.main.bounds.size.width, height: 10)
}
}
class CustomNavigationController : UINavigationController {
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
navigationBar.frame.size.height = 10
}
}
Thanks in advance!
Try the below codes,
override func viewDidLayoutSubviews()
{
super.viewDidLayoutSubviews()
let height = CGFloat(72)
navigationBar.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: height)
}