iOS 11.2 - Search Controller Bar background is clear when inside Navigation Bar with Large Title

1.1k Views Asked by At

so I just updated to iOS 11.2, and now my UISearchController's search bar is messed up. When search is active, the background behind the search bar area goes invisible / clear / transparent.

I built a test project to make sure I wasn't crazy. Here's the original setup:

navigationBar.translucent = YES;
navigationBar.barTintColor = [UIColor orangeColor];

self.navigationItem.searchController = myUISearchController;

Here's how it should appear:

With <code>prefersLargeTitles</code> off


But if I use large titles and a background image, then the result is this:

navigationBar.prefersLargeTitles = YES;
[navigationBar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];

With <code>prefersLargeTitles</code> on


If anyone finds a solution to this, I'd really appreciate the help.

✌️

1

There are 1 best solutions below

0
On

Aside from just bailing on the background image or large title, here's the only solution I've come up with.

Disable large titles before search appears, and enable it again when it dismisses. Kind of sucks but seems to do the trick.

self.navigationItem.searchController.delegate = self;

...

- (void)willPresentSearchController:(UISearchController *)searchController {
    self.navigationController.navigationBar.prefersLargeTitles = NO;
}

- (void)willDismissSearchController:(UISearchController *)searchController {
    self.navigationController.navigationBar.prefersLargeTitles = YES;
}