dmo
dmo

Reputation: 63

Color of status bar on Xcode 9.3 not changing despite overriding

I've used the following code:

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

It does work on my initial view controller scene, but it does not work on any other ones.

I've put the same function on each viewcontroller's Swift file.

Thanks in advance.

Upvotes: 0

Views: 1444

Answers (4)

Umesh Verma
Umesh Verma

Reputation: 876

1.Change in info.plist the row View controller-based status bar appearance and set it to NO

2.Change in appDelegate.swift in didFinishLaunchingWithOptions

UIApplication.shared.statusBarStyle = .lightContent

Upvotes: 0

pkc
pkc

Reputation: 8516

Perform the below changes to keep the status bar of color white.

  • Set View controller-based status bar appearance in info.plist = No
  • In AppDelegate, set UIApplication.shared.statusBarStyle = .lightContent

Upvotes: 0

Rashed
Rashed

Reputation: 2425

  1. You can change the info.plist the row View controller-based status bar appearance and set it to NO

  2. Then put this line of code in your appDelegate.swift in didFinishLaunchingWithOptions

    UIApplication.shared.statusBarStyle = .lightContent

Upvotes: 3

Muzahid
Muzahid

Reputation: 5186

When you override preferredStatusBarStyle in a viewcontroller then it will work for that controller. But if you want to change whole application status bar style then put this line of code in you AppDelegate class.

UIApplication.shared.statusBarStyle = .lightContent

Upvotes: 0

Related Questions