Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 740
Cody Avatar asked Nov 28 '22 08:11

Cody


2 Answers

hide the navgationBar when the ViewController init ViewController.navigationController?.setNavigationBarHidden(true, animated: false)

like image 88
Dan Avatar answered Dec 06 '22 23:12

Dan


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

like image 25
Cody Avatar answered Dec 06 '22 23:12

Cody