0

Tell me, please, is there a way to change the color of the status bar text for the Navigation Bar?

UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent

deprecated in iOS 13.0

What to use instead UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent?

Мария G
  • 59
  • 1
  • 7
  • Does this answer your question? [How to change status bar style - iOS 12](https://stackoverflow.com/questions/52238121/how-to-change-status-bar-style-ios-12) – jnpdx Mar 01 '21 at 16:11
  • As I wrote above, the method suggested in the answer is deprecated in iOS 13. What can I use instead? – Мария G Mar 01 '21 at 16:24
  • 1
    The answers that I linked to suggest using `Info.plist` and overriding `preferredStatusBarStyle`. I'm not seeing any evidence that they are deprecated, whereas the method that you listed in your question was deprecated in iOS 9.0 and MacCatalyst 13.0. – jnpdx Mar 01 '21 at 16:29
  • Thanks, but is not work for me( I use `View controller-based status bar appearance`. (try `YES`. and `NO`, it's not change result). And I use `override var preferredStatusBarStyle: UIStatusBarStyle { return (UserDefaults.standard.object(forKey: "theme") == nil ? "light" : UserDefaults.standard.string(forKey: "theme")) == "dark" ? .lightContent : .darkContent } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) setNeedsStatusBarAppearanceUpdate() }` – Мария G Mar 02 '21 at 03:28

1 Answers1

0

In info.plist View controller-based status bar appearance: YES

In class MyTabBarController : UITabBarController (he set my rootViewControllers)

override var preferredStatusBarStyle: UIStatusBarStyle {
 return (UserDefaults.standard.object(forKey: "theme") == nil ? "light" : UserDefaults.standard.string(forKey: "theme")) == "dark" ? .lightContent : .darkContent
 }

 override var childForStatusBarStyle: UIViewController? {
 return nil
 }
Мария G
  • 59
  • 1
  • 7