Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StatusBar in searchController and searchResultsController problems : iOS 8

Hi, here is my problem:

In my AppDeleagate's didFinishLaunchingWithOptions: method i have a method [self configureUINavigationControllerStlyle]; which configures the status bar and all the navigation bar appearance of my app (I have UINavigationController and UITabbarController working together in my App).

-(void) configureUINavigationControllerStlyle {

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

UINavigationController *navigationController = (UINavigationController *)[tabBarController.viewControllers objectAtIndex:0];

navigationController.navigationBar.translucent = NO;

[[UINavigationBar appearance] setBarTintColor: [CustomColor getAwesomeColor:@"colorBlue3_1"]];

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

[[UINavigationBar appearance]  setTitleTextAttributes:@{
NSForegroundColorAttributeName : [UIColor whiteColor],
NSFontAttributeName: [UIFont fontWithName:@"AvenirNext-DemiBold" size:17.0]
 }];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

}

Also In my info.plist i set: View controller-based status bar appearance to "NO"

Everything worked great and all the controllers inside my app have their status bars with blue background and white text color. But not the uisearchcontroller and uisearchresultscontroller.

My root TableViewController looks like this:

https://www.dropbox.com/s/oqcozos89x9yqhg/Screen%20Shot%202014-12-11%20at%2016.21.06.jpg?dl=0

I integrated searchController and searchResultsController in my app. The logic works well, but I don't understand how to deal with status bar appearance inside searchController and searchResultController. They don't use styles for status bar that i created in my AppDelegate.m file.

My searchController and searchResultsController look like this (Statusbar became white and text color of the status bar also became white, but I need my status bar to be the same color as in my Home View Controller (blue background and white text color).

https://www.dropbox.com/s/26skdz7gvehmwl4/Screen%20Shot%202014-12-11%20at%2016.21.16.png?dl=0

Another bug: When I use

navigationController.navigationBar.translucent = NO;

in my AppDelegate - it causes "jumping or stretching down" of my home tableview at the moment of going back from detail view controller after using search controller. When I don't set translucent property - there is no "jumping" .

Maybe anyone knows how to fix that status bar colours problems when using searchController in iOS 8.

If I use default colours (don't add any changes to my AppDelegate), everything works fine, but I need custom status bar colours in my app.

like image 653
Adelmaer Avatar asked Dec 11 '14 14:12

Adelmaer


1 Answers

You will need to subclass UISearchController and override preferredStatusBarStyle like so:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
like image 83
Ric Santos Avatar answered Oct 20 '22 16:10

Ric Santos