0

I'm using Xcode Version 10.0 beta 4. I keep getting this warning Setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController preferredStatusBarStyle]. I change the status bar style in my scrollViewDidScroll function with UIApplication.shared.statusBarStyle = .default after the user has scrolled down far enough. Is there any way I can continue to do this without receiving this warning?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Brandon Cornelio
  • 333
  • 3
  • 14

2 Answers2

4

What you have been doing was always wrong; it's just that the expected deprecation has finally come.

Do what the error message says. Implement preferredStatusBarStyle in the top-level view controller (or some view controller that it consults). When the value changes, call setNeedsStatusBarAppearanceUpdate so that preferredStatusBarStyle will be consulted again.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Couldn't implement this before for whatever reason so I settled with the other way of doing it. I guess I was stumped setNeedsStatusBarAppearanceUpdate. Appreciate the support. – Brandon Cornelio Jul 20 '18 at 23:11
0

Actually statusBarStyle was deprecated, use below code in AppDelegate to remove the warning.

var darkMode = false
var preferredStatusBarStyle : UIStatusBarStyle {
    return darkMode ? .default : .lightContent
}