当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - 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.

网友答案:

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.

网友答案:

My approach is the following:

self.definesPresentationContext = YES;

and implement this function:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDarkContent;
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: