Has anyone been able to add a UISearchController
to the navigation bar in iOS 11, when LargeTitles = true
? I can set the the NavigationItem.TitleView
to a UISearchBar
object, but it doesn't look good. Setting NavigationItem.SearchController
to a UISearchController
doesn't do anything; no search bar is displayed. Heres the code:
if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
{
// doesn't work. No search bar is displayed
var searchController = new UISearchController((UIViewController)null);
navigationItem.SearchController = searchController;
navigationItem.HidesSearchBarWhenScrolling = false;
// This works, but doesn't look good (search bar is too small & overlaps the top part of the Large Title)
// var searchBar = new UISearchBar();
// ...
// navigationItem.TitleView = searchBar;
}