There are two viewcontrollers.
Controller A with status bar. Controller B without status bar.
When I push A to B, there is still the status bar in B.
To hide the status bar in B. I set below in B.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UIApplication.shared.isStatusBarHidden = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UIApplication.shared.isStatusBarHidden = false
}
I have tried to set the prefersStatusBarHidden to true, but it failed. When I use present, there is no status bar in B.
Do you know the reason why it doesn't work? What's wrong with the codes? Thanks in advance.