简体   繁体   中英

Status Bar Content colour not changing to white in navigation controller using Swift

I have used UINavigationController to create navigation flow, first screen is List view controller and second one is detail view controller of list item.

I am hiding navigation bar in both view controllers because I have created my own top bar.

Now I am trying to change status bar content to light content but

override var preferredStatusBarStyle: UIStatusBarStyle{
   .lightContent
}

This is not getting called. I read multiple answers about changing status bar content style when UINavigationController is used but none of them help because I am hiding navigation bar.

Navigation controller is embedded in TabBarController.

Attaching the image for reference Image

First hide navigation bar in viewDidLoad() by hit the below code

self.navigationController?.navigationBarHidden = true

Add the status bar code in ViewController like you did

override var preferredStatusBarStyle: UIStatusBarStyle{
   return .lightContent
}

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