Before I start I would to apologise if this question is duplicated as I seen plenty of question but I can't find out what I need.
I want to create a global Status, navigation, toolbar bar style and, if possible, the bottom part of the view on iPhones X onwards from my app delegate only so I don't have to set it form each Viewcontroller.
So far I have:
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
and a function called inside the didFinishLaunchingWithOptions method
private func setupNavigationBarStyle(){
UIApplication.shared.statusBarView!.backgroundColor = UIColor.AppColors.statusBar
UIApplication.shared.statusBarStyle = .lightContent
UINavigationBar.appearance().barTintColor = .brown
UINavigationBar.appearance().tintColor = .green
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.yellow]
UINavigationBar.appearance().isTranslucent = false
}
I attach a dummy design for my view controller using the storyboard
UIApplication.shared.statusBarStyle = .lightContent is deprecated and it shows a warning and I don't want that.
How can I change the color for the bottom for iPhone X onwards (currently in red and and where the Horizontal line is).
Can I change statusBarStyle for another not defined and change the text color in my status bar Purple?
I hope it will help you
UIApplication.shared.statusBarStyle = .lightContent is deprecated and it shows a warning and I don't want that.
Go to Project -> Target, Set Status Bar Style to Light
it is not possible to modify the color, and you shouldn’t worry about it, since it’s out of your control and guaranteed to be visible.For Info(https://medium.freecodecamp.org/reverse-engineering-the-iphone-x-home-indicator-color-a4c112f84d34).
Can I change statusBarStyle for another not defined and change the text color in my status bar Purple?
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }
statusBar.backgroundColor = color
}
//Use self.setStatusBarBackgroundColor(color: .purple)
Thanks