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
You can change the status bar text color by using this extension:
extension UIApplication {
enum ColorMode {
case dark, light, customColorLowerThanIOS13(_ color: UIColor)
}
func setStatusBarTextColor(_ mode: ColorMode) {
if #available(iOS 13.0, *) {
guard let appDelegate = delegate as? AppDelegate else { return }
var style: UIUserInterfaceStyle
switch mode {
case .dark:
style = .dark
default:
style = .light
}
appDelegate.window?.overrideUserInterfaceStyle = style
} else {
if let statusBar = UIApplication.shared.value(forKey: "statusBar") as? UIView {
var color: UIColor
switch mode {
case .dark:
color = .white
case .light:
color = .black
case .customColorLowerThanIOS13(let customColor):
color = customColor
}
statusBar.setValue(color, forKey: "foregroundColor")
}
}
}
}
Using:
UIApplication.shared.setStatusBarTextColor(.dark)
UIApplication.shared.setStatusBarTextColor(.light)
UIApplication.shared.setStatusBarTextColor(.customColorLowerThanIOS13(.red))