Color text of status bar in XCode 6-b3 (Swift)

后端 未结 5 2067
闹比i
闹比i 2021-02-01 06:32

I\'ve try to modify status bar color text but no one answer from this thread doesn\'t work. Any especially for XCode 6?

I\'ve tried insert:

override func         


        
5条回答
  •  情话喂你
    2021-02-01 07:07

    Be sure to set the View controller-based status bar appearance in your info.plist file to Yes.

    Furthermore, if you are in a UINavigationController, you cannot simply set the style in ViewControllers in it. Subclass the UINavigationController and add this to it:

    override func preferredStatusBarStyle() -> UIStatusBarStyle {
    
        if let vc = self.viewControllers?.last as? UIViewController {
            return vc.preferredStatusBarStyle()
        }
    
        return super.preferredStatusBarStyle()
    }
    

    Now you can set the bar style in the UIViewController subclass and the UINavigationController will listen to it :).

提交回复
热议问题