有没有办法改变 UINavigationController Swift Xcode 中 UINavigationBar 的高度?

Is there a way to change the height of a UINavigationBar in a UINavigationController Swift Xcode?

有没有办法改变(即减小)UINavigationController 中UINavigationBar 的高度?我尝试了以下无济于事:

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
    }

}

提前致谢!

试试下面的代码,

override func viewDidLayoutSubviews()
{
   super.viewDidLayoutSubviews()
   let height = CGFloat(72)
   navigationBar.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: height)
}