-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change colour on selection list #58
Comments
@shaunwurdeman However, since classes related to SuggestionList are defined in private, If you want to extend it yourself. When using a custom render. public class MyAutoSuggestBoxRenderer : AutoSuggestBoxRenderer
{
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == nameof(MyAutoSuggestBox.ItemsSource))
{
Control.SelectionList.BackgroundColor = UIColor.White;
SetTextColor(Control.SelectionList, UIColor.Black);
}
}
private void SetTextColor(UITableView tableView, UIColor color)
{
var sections = tableView.NumberOfSections();
if (sections <= 0) return;
for (var sec = 0; sec < sections; sec++)
{
var rows = tableView.NumberOfRowsInSection(sec);
if (rows <= 0) break;
for (var row = 0; row < rows; row++)
{
var path = NSIndexPath.FromRowSection(sec, row);
var cell = tableView.CellAt(path);
if (cell?.TextLabel?.Font != null)
{
cell.TextLabel.TextColor = color;
}
}
}
}
} |
I'll be addressing this once the spec for darkmode support in Forms gets finished: xamarin/Xamarin.Forms#7304 Until then, I'm a little bit reluctant to make changes to default values as that might actually prevent me from adding proper darkmode support in the future. The above suggestion should be good (there's also a sample in the app showing how to do custom styling in ios, similar to the above approach). One could even argue this control behaves correctly in DarkMode, and it's the rest of Xamarin.Forms that doesn't ;-) |
Is there a way to change the selection list background colour and text colour?
This is specifically in reference to iOS 13's dark mode, where the selection list automatically becomes black with white text. This clashes with the rest of a light themed app's look and feel.
Thanks in advance.
The text was updated successfully, but these errors were encountered: