简体   繁体   中英

How to hide status bar + using white light content in another view controller(swift)?

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.

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

Add controller-based status bar false in info.plist

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM