vara vara - 5 months ago 50
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)