Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Adding search bar to navigation bar in iOS 11

$
0
0

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;
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>