Mikael
Mikael

Reputation: 2395

UINavigationBar moving under status bar when another viewController hides status bar

The problem is simple, the Profile viewController has a NavigationBar just under the status bar.
I push another viewController on top of the current one. This new viewController hides the status bar.

When I go back to the Profile viewController, the navigationBar has moved up by the size of the status bar height.

I tried to force a layout refresh in my viewWillAppear but it doesn't work.

Any ideas?

enter image description here

Upvotes: 0

Views: 342

Answers (3)

Ketan Parmar
Ketan Parmar

Reputation: 27448

Implement viewDidDisappear in that presented viewcontroller and show status bar again before come to profileview controller.

  override func viewWillDisappear(animated: Bool) {


    UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: UIStatusBarAnimation.Fade)
}

Upvotes: 0

Iyyappan Ravi
Iyyappan Ravi

Reputation: 3245

Use this below code,

override func viewWillDisappear(animated: Bool) {
    navigationController?.setNavigationBarHidden(navigationController?.navigationBarHidden == false, animated: false)
}

hope its helpful

Upvotes: 1

Bhadresh Kathiriya
Bhadresh Kathiriya

Reputation: 3244

add code in plist file hide status bar in your app:

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

Upvotes: 0

Related Questions