如何更改UINavigationBar高度?

时间:2018-05-27 17:24:23

标签: ios uinavigationbar

是否可以在ios 11中更改UINavigationBar高度? 我试过这个:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let height: CGFloat = 50 //whatever height you want to add to the existing height
    let bounds = self.navigationController!.navigationBar.bounds
    self.navigationController?.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height + height)

}

和此:

extension UINavigationBar {
    override open func sizeThatFits(_ size: CGSize) -> CGSize {
        return CGSize(width: UIScreen.main.bounds.width, height: 100)
    }
}

并且它们似乎都不起作用。

0 个答案:

没有答案