vara vara - 1 year ago 84
Swift Question

Navigation bar Height is not changed in ViewDidLoad() programmatically?

Hi I have tried to change the

UINavigationBar
height progrmatically it has not changed in
viewDidLoad
. but its working
viewDidAppear()
but once I have do my application in background after if open the app it has not changed it going default height.please any one help. thanks advance.

let bounds = self.navigationController!.navigationBar.bounds
self.navigationController!.navigationBar.frame = CGRect(x: 0, y: 0, width: bounds.width, height: 66)

Answer Source

Add UINavigationBar extension with your viewcontroller

extension UINavigationBar {
    override open func sizeThatFits(_ size: CGSize) -> CGSize {
        return CGSize(width: UIScreen.main.bounds.size.width, height: 80.0)
    }
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download