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

Setting iOS Navigation Searchbar Text Color (Custom Renderer)

$
0
0

Hello,

I wasn't sure if this should be placed in this forum or the iOS forum.

I am using the 11's Searchbar in the Navigation area. I have set the navigation background in Xamarin.Forms Standard project with the following method:
var searchNavigationContainer = new FreshNavigationContainer(searchPage){BarBackgroundColor = Color.FromHex("#1D3557"), BarTextColor = Color.FromHex("#A8DADC") };

This sets the color appropriately:

However, when attempting to type in the searchbar, the text does not show (I believe due to the color being the same as the background):

A snippet of my custom renderer page:
` var hideSearchbarWithScroll = _customSearchPage?.HideSearchbarWithScroll ?? false;
var searchController = new UISearchController(searchResultsController: null)
{
HidesNavigationBarDuringPresentation = false,
DimsBackgroundDuringPresentation = false,
};
searchController.SearchResultsUpdater = this;
searchController.SearchBar.SearchBarStyle = UISearchBarStyle.Minimal;
searchController.SearchBar.TintColor = UIColor.White;
searchController.SearchBar.BarTintColor = UIColor.White;
using (var searchKey = new NSString("_searchField"))
{
var textField = (UITextField)searchController.SearchBar.ValueForKey(searchKey);
textField.TextColor = UIColor.White;
}

            if (_customSearchPage?.Placeholder != null)
            {
                searchController.SearchBar.Placeholder = _customSearchPage?.Placeholder;
            }`

As you can see I have tried to change the foreground text color of the search bar.
However, it's clearly not working!
How do I change the foreground/text color of the textbar, so that I can see what I'm typing?

I would appreciate any assistance in this!

Many thanks,
Richard


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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