Take Xamarin.Forms sample, add the large titles to nav page, fails to show on iOS 13
https://github.com/xamarin/xamarin-forms-samples/tree/master/Navigation/TabbedPageWithNavigationPage
iOS 13 should behave as 12 and show titles as expected
iOS 13 shows nothing in navigation bar.
Short video of issue
https://www.dropbox.com/s/0ptzu3ychwinnk8/nolargetitles.mov?dl=0
This I believe is related to the new iOS 13 UINavigationBarAppearance including standardAppearance and scrollEdgeAppearance which are not supported properly by Xamarin Forms.
This also breaks any BackgroundImage you are setting on your MainPage. You just get a white background unless you disable LargeTitles.
I've tried working around this using Xamarin.iOS code, but without delving into the platform renderer and the navigationbar view, this is near impossible.
We've worked around this issue by doing the following in a custom renderer for NavigationPage:
var barBackgroundColor = NavPage.BarBackgroundColor;
NavigationBar.StandardAppearance.BackgroundColor = barBackgroundColor == Color.Default
? UINavigationBar.Appearance.BarTintColor
: barBackgroundColor.ToUIColor();
NavigationBar.StandardAppearance.TitleTextAttributes = NavigationBar.TitleTextAttributes;
NavigationBar.StandardAppearance.LargeTitleTextAttributes = NavigationBar.LargeTitleTextAttributes;
NavigationBar.ScrollEdgeAppearance = NavigationBar.StandardAppearance;
You saved my life, @Jeff-Bridges. Here's what the whole renderer looks like
using NAMESPACE.iOS.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(NavigationPage), typeof(LargeHeaderFixingNavigationPageRenderer))]
namespace NAMESPACE.iOS.Renderers
{
public class LargeHeaderFixingNavigationPageRenderer : NavigationRenderer
{
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
if (Element is NavigationPage navigationPage)
{
var barBackgroundColor = navigationPage.BarBackgroundColor;
NavigationBar.StandardAppearance.BackgroundColor = barBackgroundColor == Color.Default
? UINavigationBar.Appearance.BarTintColor
: barBackgroundColor.ToUIColor();
NavigationBar.StandardAppearance.TitleTextAttributes = NavigationBar.TitleTextAttributes;
NavigationBar.StandardAppearance.LargeTitleTextAttributes = NavigationBar.LargeTitleTextAttributes;
NavigationBar.ScrollEdgeAppearance = NavigationBar.StandardAppearance;
}
}
}
}
Have the same issue with background color isn't working with Large Titles.
The workaround mentioned above works great.
But I just find out that the latest iOS 13.2 beta it restores the behavior like before.
On this beta, everything looks solved/ok with my unchanged apps
So maybe more an iOS13 bug instead of Xamarin?!
Update:
It only works again like before with my apps in the App Store(compiled with Xamarin.iOS 12)
When compiling the same app (same XF framework) with latest Xamarin.iOS through VS ( and transfer it to an iPhone) it does not work and bgcolor etc is still missing.
But I just find out that the latest iOS 13.2 beta it restores the behavior like before.
On this beta, everything looks solved/ok with my unchanged apps
So maybe more an iOS13 bug instead of Xamarin?!
@mnidhk My phone has gotten only 13.1.3 so far, and I can see the issue described here. So, if I understand you correctly, your published apps still use 12 and that's why they are working as expected?
Correct! So for apps, compiled with ios12, there is a patch by Apple automatically. New compiled apps with iOS 13 are still affected with this issue, also in beta 13.2.
OK. I submitted a PR to fix this issue.
Most helpful comment
You saved my life, @Jeff-Bridges. Here's what the whole renderer looks like