Search code examples
iosswiftuinavigationcontrolleruinavigationbar

How to hide navigation bar immediately in Swift?


My UIViewController is embed in a navigation controller:

enter image description here

I tried setNavigationBarHidden:animated: to hide notificationbar. It works but there are about 2 seconds delay. Here is the screenshot:

enter image description here

My usage is to add it in viewDidLoad():

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.setNavigationBarHidden(true, animated: false)
}

How to hide navigationbar immediately when screen is launched ?


Solution

  • According the official document:

    Every app must supply a launch file or at least one static image.

    The delay is caused by the launch screen from the your main storyboard file. Don't set launch screen file to your Main.storyboard file.

    In Project settings > General -> App Icons and Launch Images -> Launch Screen File:

    enter image description here

    Set it to another storyboard:

    enter image description here