I have the following code in my app, specifically in viewDidLoad:
that sets up my UISearchController
.
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.definesPresentationContext = NO;
self.searchController.searchBar.scopeButtonTitles = @[];
self.searchController.searchBar.searchBarStyle = UISearchBarStyleProminent;
[_tableView setTableHeaderView:_searchController.searchBar];
Whenever the search bar (which is added to the tableView
) is invoked, the UIStatusBar
color changes from UIStatusBarStyleLightContent
to dark (white to black). Now, I figured out if I set,
self.definesPresentationContext = NO;
to the following:
self.definesPresentationContext = YES;
the issue is solved and the UIStatusBar
color is preserved. However, another issue arises. When self.definesPresentationContext
is set to YES
, upon invocation the search bar shifts down for some reason, coincidently (or rightfully so) right under where the bottom of the UIRefreshControl
displays on the tableView
.
Setting View-controller based status bar appearance
to No
is not a solution if you want the view controllers to define how the status bar looks.
My solution consisted of two things:
definesPresentationContext
set to YES
extendedLayoutIncludesOpaqueBars
to YES
)