2

I have a UINavigationcontroller with following set in rootviewcontroller or first controller

override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        self.navigationBar.shadowImage = UIImage()

    }

The reason is I don't want UINaviationBar to be shown.

Now I am pushing another viewcontroller into the stack and I want to have UINavigationBar in the second controller and using below code to achieve this

override func viewWillAppear(_ animated: Bool) {

        super.viewWillAppear(animated)

        self.navigationController!.navigationBar.setBackgroundImage(UIImage(named:"mainhead.png"), for: UIBarMetrics.default)
    } 

Now popping second controller to first and using below code in second controller viewWillDisappear to hide the UINavigationBar

 override func viewWillDisappear(_ animated: Bool) {

        super.viewWillDisappear(animated)

        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        self.navigationController?.navigationBar.shadowImage = UIImage()

    }

Above logic works but the transition is not smooth. I am able to see the UINavigationBar until first viewcontroller appears and then the UINavigationbar disappears

How do I make the transition smooth? I can hide and unhide but I am wondering what is the right way of doing this

Thanks

slysid
  • 5,236
  • 7
  • 36
  • 59
  • possible duplicate http://stackoverflow.com/questions/42120482/navigation-bar-is-moving-up-to-statusbar/42909654#42909654 – Joe Apr 28 '17 at 03:09
  • check this post may help http://stackoverflow.com/questions/39835420/navigationbar-delay-updating-bartintcolor-ios10/40255483#40255483 – Joe Apr 28 '17 at 03:12

0 Answers0