Status bar Light content doesnot appear in Navigation Controller using Split view controller

自古美人都是妖i 提交于 2020-01-07 05:01:27

问题


When adding status bar as light content. its appearing fine in login screen. it changes to white in login screen. after successful login I have an split view and navigation controller.

I have added the code but still it shows black.

1) added below line in view contoller.

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

2) info.plist

View controller-based status bar appearance -> NO

3) then came across this line and added this one also.

  controller.navigationController?.navigationBar.barTintColor = UIColor.white

4) then came across article where it was mentioned to add extension if we need to change status bar in navigation but still nothing works

extension UINavigationController
{
    override open var preferredStatusBarStyle: UIStatusBarStyle {
        get {
            return .lightContent
        }
    }
}

I have added and tried with each of them but still it shows black status bar.


回答1:


try this

 override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}



回答2:


There's another approach to do the same.

self.navigationController?.navigationBar.barStyle = .black

The idea behind this is that UIBarStyle figures out content color of UIStatusBar. Upon passing .black it figures out that background is black and UIStatusBarStyleLightContent mode is required. And when you pass .default it figures out that background is light and returns black content or UIStatusBarStyleDefault.



来源:https://stackoverflow.com/questions/46485347/status-bar-light-content-doesnot-appear-in-navigation-controller-using-split-vie

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!