1
votes

I want to hide status bar in a first controller, but I also want it to appear in a second controller in a lightContent.

I used:

UIApplication.shared.statusBarStyle = .lightContent

for light content and

override var prefersStatusBarHidden: Bool {
    return true
}

to hide status bar.

My problem is that set View controller-based status bar appearance to Yes/No in .plist file will disable one or another.

2
Do you use a tab bar and/or navigation controller?André Slotta
Navigation controller, but I solved it already by: navigationController?.navigationBar.barStyle = .blackTranslucent I should have use my brain in first placeDaniel Kubicek

2 Answers

1
votes

If you want to hide status bar in a ViewController you can easily do it using this code

In viewWillAppear

UIApplication.shared.isStatusBarHidden = true

In viewWillDisappear

UIApplication.shared.isStatusBarHidden = false

In info.plist

<key>UIViewControllerBasedStatusBarAppearance</key><false/>

In didFinishLaunchingWithOptions

UIApplication.shared.statusBarStyle = .lightContent
0
votes

Add controller-based status bar false in info.plist

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>