vara vara - 2 years ago 145
Swift Question

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

Hi I have tried to change the

height progrmatically it has not changed in
. but its working
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