xamarinxamarin.iosuinavigationbarbartintcolor

BarTintColor does not work with PrefersLargeTitles in iOS 13 in Xamarin


As I am trying to prepare our app for iOS 13, I am running into a rendering issue I can not fix.

We have code like this in our ViewDidLoad:

this.NavigationController.SetNavigationBarHidden(false, false);
this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB(3, 117, 178);
this.NavigationController.NavigationBar.TintColor = UIColor.White;
this.NavigationController.NavigationBar.Translucent = false;
this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes
{
ForegroundColor = UIColor.White
};
View.BackgroundColor = UIColor.White;

this.NavigationController.NavigationBar.PrefersLargeTitles = true;
this.NavigationController.NavigationBar.LargeTitleTextAttributes = new UIStringAttributes
{
ForegroundColor = UIColor.White
};

In iOS 12, it looks like this

Just compiling for 13, it now looks like

But if I scroll, it does look right (except for search)

We got a lot of this information previously from the dev blogs https://devblogs.microsoft.com/xamarin/go-large-ios-11/, and I tried several iterations there. I even tried putting part of this in our AppDelegate too.

I can change the text (Its actually working here, thats why you see nothing). It works fine on a page without PrefersLargeTitles set.


Solution

  • This was a bug in Xamarin before 12.99.3.5.

    In 12.99.3.5, the new ScrollEdgeAppearance property was available, but also did not work.

    This is fixed in 12.99.4.1 and later.

    Progress can be tracked at https://github.com/xamarin/xamarin-macios/issues/6834