Xamarin Forms iOS 导航栏

3
需要在Xamarin Forms IOS上寻求帮助(Android正常运行)。当我在选项卡项目上打开一个新页面时,IOS上的导航栏会变为INVISIBLE,但是当向上或向下滚动页面时,导航栏会出现,虽然是不可见的,但返回按钮仍然存在并且可以被点击。该项目的所有其他页面都有相同的行为,返回按钮存在,但是不可见。如下图所示。 如何设置所有页面的导航栏可见?

see GIF here

1个回答

2
这是iOS15的默认行为更改,为了解决这个问题,我们只需要修改UINavigationBarAppearancescrollEdgeAppearance属性。

将以下代码放置在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


如果问题已经解决,请考虑将其标记为答案,以帮助其他遇到相同问题的人。 - ColeX
嗨,Colex,我是stackoverflow上的新手。如何标记答案?另外,当内容向上滚动时,我的选项卡栏变得透明了,我也遇到了同样的问题。 - ifoxbr
https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work - ColeX
谢谢,伙计。我仍然不知道为什么编程这样的东西都这么难(我只想给导航栏设置一个背景颜色?),但这帮了我很多!另外,如果你想在 Xamarin 中使用自定义颜色,可以这样做:Color.FromHex("#[十六进制颜色值]").ToUIColor(); - RolandMakkelie

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接