mlevi
mlevi

Reputation: 1463

UISearchBar changing status bar color to white

I have a UISearchBar and for some odd reason whenever the search bar is tapped on the status bar color changes from black to white. I don't want the status bar color to change. Any ideas? Thanks.

Upvotes: 4

Views: 4221

Answers (2)

gklka
gklka

Reputation: 2564

My approach is the following:

self.definesPresentationContext = YES;

and implement this function:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDarkContent;
}

Upvotes: 0

mbm29414
mbm29414

Reputation: 11598

The accepted answer here seems to indicate that the UISearchBar sends a call to its "parent" UINavigationController when it begins editing.

Therefore, you seem to have 2 options:

  1. You could simply override the tintColor for the UINavigationController for you UITableViewController, or

  2. You could write a simple UINavigationController subclass that overrides -preferredStatusBarStyle, returning the desired style.

It looks like #1 gives you what you need with minimal fuss/code.

Upvotes: 8

Related Questions