简体   繁体   中英

Hide iOS NavigationBar on one ViewController - weird animation happening

I have a standard UINavigationController for an iOS application in Swift 5 in which I'd like to hide the Navigation Bar on the first ViewController in the stack.

My storyboard is essentially:

UINavigationController -> ViewControllerA -> ViewControllerB

with simple Show segues.

In ViewControllerA I put the following:

override func viewWillAppear(_ animated: Bool) {
  super.viewWillAppear(animated)
  self.navigationController?.navigationBar.isHidden = true
}

In ViewControllerB I put the following:

override func viewWillAppear(_ animated: Bool) {
  super.viewWillAppear(animated)
  self.navigationController?.navigationBar.isHidden = false
}

But in the simulator the transition from A->B presents this weird, like, "scooping" animation and I cannot figure out how to get rid of it.

Thoughts? Thank you in advance!

ViewController 过渡中的奇怪动画

还有另一种隐藏导航栏的方法,您可以在其中将 'animated' 设置为 false,这可能会对您有所帮助。

self.navigationController?.setNavigationBarHidden(true, animated: false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM