iOS 13 Setting status bar text color from within UINavigationController

前端 未结 3 2036
轮回少年
轮回少年 2021-01-21 17:34

So before iOS 13, I was setting the NavigationController.NavigationBar.BarStyle to control the colour of the text int he status bar. But now witht he new UINavigationBarAppearan

3条回答
  •  时光说笑
    2021-01-21 18:03

    The barStyle does still work under limited conditions. You can use the barStyle or UIBarAppearance but not both, and you can’t use the barStyle if you use large titles.

    Of course you could trivially solve the problem just by subclassing UINavigationController. A bit hacky, but easy.

    override var childForStatusBarStyle : UIViewController? {
        return self.topViewController
    }
    

    What you are expected to do in iOS 13, though, is leave the status bar style alone and let it change automatically in response to the user interface style (light or dark mode). Use a light bar color in light mode and a dark bar color in dark mode and all will be well.

提交回复
热议问题