UINavigationBar moving under status bar when another viewController hides status bar

我是研究僧i 提交于 2019-12-13 05:51:47

问题


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?


回答1:


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)
}



回答2:


Use this below code,

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

hope its helpful




回答3:


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

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


来源:https://stackoverflow.com/questions/37437075/uinavigationbar-moving-under-status-bar-when-another-viewcontroller-hides-status

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!