1
votes

Throughout my app I have set the status bar style to light content.enter image description here

However, when the search controller is active, it resets to the default style: enter image description here

I have tried everything to fix this, including checking if the search controller is active in an if statement, and then changing the tint color of the navigation bar to white, and setting the status bar style to light content. How do I fix this?

2

2 Answers

6
votes

a couple of option, and this could be a problem that is a bug, but in the mean time, have you tried this:

Option 1:

info.plist, set up the option in your info.plist for "Status bar style", this is a string value with the value of "UIStatusBarStyleLightContent"

Also, in your infor.plist, set up the variable "View controller-based status bar appearance" and set it's value to "NO"

Then, in each view controller in your app, explicitly declare the following in command in your initializers, your ViewWillAppear, and your ViewDidLoad

UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent

Option 2:

In your info.plist set up the option for "Status bar style" to "UIStatusBarStyleLightContent". Also, in your infor.plist, set up the variable "View controller-based status bar appearance" and set it's value to "YES"

Then, in each view controller place the following methods

override func preferredStatusBarStyle() -> UIStatusBarStyle {
            return UIStatusBarStyle.LightContent;
        }

override func prefersStatusBarHidden() -> Bool {
    return false
}

Also, you may need to do something like this:

    self.extendedLayoutIncludesOpaqueBars = true

Also, I translated it to Swift code for you

3
votes

Add this to your code to make the status bar style to Light :

   override func preferredStatusBarStyle() -> UIStatusBarStyle {

            return UIStatusBarStyle.LightContent;
        }

You can also set the status bar in the info list and it will remain same in you app until it is override in the code for paticular view controller.

enter image description here