preferredStatusBarStyle var not working in iOS12?

前端 未结 2 1900
深忆病人
深忆病人 2020-11-28 13:36

Adding

application.statusBarStyle = .lightContent

to my AppDelegate\'s didFinishLaunchingWithOptions method nor adding

ove         


        
2条回答
  •  渐次进展
    2020-11-28 14:09

    If you choose a same status bar color for each View Controller:

    UIViewControllerBasedStatusBarAppearance
    
    

    Ad this to your Info.plist and set status bar color from Project -> Targets -> Status Bar Style by desired color.

    On the other hand, in your case, you have a navigation controller which is embedded in a view controller. Therefore, you want to different status bar color for each page.

    UIViewControllerBasedStatusBarAppearance
    
    

    Ad this to your Info.plist. Then, create a custom class for your NavigationController. After that you can implement the method:

    class LightContentNavigationController: UINavigationController {
    
        override var preferredStatusBarStyle: UIStatusBarStyle {
            return .lightContent
        }
    }
    

    Thats it! Please, inform me whether this was useful!

提交回复
热议问题