I have 2 StoryBoard
in my project and all ViewController
in my 1st storyBoard
are of .lightContent
statusBarStyle
and all ViewController
in my 2nd storyBoard
are of .default
statusBarStyle
.
For that i have done below steps.
1.View controller-based status bar appearance
is true
2 Already use below code.
extension UINavigationController {
open override var preferredStatusBarStyle: UIStatusBarStyle {
return topViewController?.preferredStatusBarStyle ?? .default
}
}
When i set 2nd storyBoard
ViewController
as rootController from 1st storyBoard
statusBar style changing but i am facing below issue.
When i set 1st storyBoard ViewController
as rootController, statusBarStyle update after few seconds.
Not Proper
After Few Seconds
here is my demo link : https://www.dropbox.com/s/ijqg73zm1jxbokc/statusBarDemo.zip?dl=0
UPDATE
MY First ViewController Code
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .default
}
@IBAction func btnInitialControllerTapped(_ sender: Any) {
let controller = UIStoryboard(name: "Initial", bundle: nil).instantiateViewController(withIdentifier: "InitialViewController") as! InitialViewController
let navController = UINavigationController.init(rootViewController: controller)
appDelegate.window?.rootViewController = navController
}
MY Second ViewController Code
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
@IBAction func btnControllerTapped(_ sender: Any) {
let storyboard = UIStoryboard(name:"Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
let navigationController = UINavigationController(rootViewController: vc)
appDelegate.window?.rootViewController = navigationController
}
Please guide me what i'm missing or what i have implemented wrongly. Any help will be appreciated. Thanks