Make sure that in your Info.plist file you have View controller-based status bar appearance
set to NO
. It would also be helpful to check that you don't programatically set the status bar to a different color in a view controller by accident. If you're using the above function, do you call self.setNeedsStatusBarAppearanceUpdate
? But you shouldn't need to write any code at all if you set Light
as the value in your project settings and NO
in your plist file.
Another option that has worked for me in the past is in your AppDelegate file, in the didFinishLaunchingWithOptions
function do this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = .lightContent
return true
}