Xamarin Forms iOS导航栏Xamarin、Forms、iOS

2023-09-04 01:32:08 作者:折月煮酒゜

我需要有关Xamarin Forms iOS的帮助(Android运行良好)。当我在选项卡式项目上打开一个新页面时,iOS上的导航栏看不见,但当上下滚动页面时,导航栏出现了,虽然看不见,但后退按钮就在那里,可以点击。项目的所有其他页面都有相同的行为,后退按钮在那里,但看不见。请参见下图。 如何将导航栏设置为所有页面都可见?

查看GIF此处:

Xamarin.iOS开发初体验

推荐答案

这是IOS15的默认行为更改,要解决这个问题,我们只需要修改UINavigationBarAppearance scrollEdgeAppearance属性。

将以下代码放在iOS项目的AppDelegate.csSceneDelegate.cs中。

UINavigationBarAppearance a = new UINavigationBarAppearance();
a.ConfigureWithTransparentBackground();
a.BackgroundColor = UIColor.Blue;
a.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = UIColor.White};


UINavigationBar.Appearance.StandardAppearance = a;
UINavigationBar.Appearance.CompactAppearance = a;
UINavigationBar.Appearance.ScrollEdgeAppearance = a;

请参阅

https://developer.apple.com/forums/thread/684454。