动态更改侧边菜单按钮/链接文本颜色Xamarin.iOS

时间:2018-11-12 10:12:34

标签: xamarin xamarin.ios

我正在使用侧面菜单iOS(不是我的选择,),但我偶然发现了一个问题,如下图所示:

enter image description here

如果您在上图中看得足够近,则红色矩形实际上会突出显示用于打开侧边菜单的文本“菜单”,并且几乎看不见。更改导航栏文本的颜色非常简单,但这似乎不会影响该颜色。

如何更改上面显示的默认颜色?

3 个答案:

答案 0 :(得分:0)

色调决定了这种颜色。

您可以通过设置全局进行更改

UINavigationBar.Appearance.TintColor

答案 1 :(得分:0)

如果您只想更改特定ViewController中菜单按钮的颜色。在ViewController的方法ViewWillAppear()中添加以下代码

public override void ViewWillAppear(bool animated)
{
   base.ViewWillAppear(animated);
   this.NavigationController.NavigationBar.TintColor = UIColor.FromRGB(xxx,xxx,xxx);
}

答案 2 :(得分:0)

NavigationPage具有一个名为BarTextColor的属性,在iOS设备上,此属性更改导航栏文本和菜单按钮文本的颜色。但是,如果要为每种颜色分别设置单独的颜色,以下解决方案可能会成为问题:

MainPage = new NavigationPage(YourPage) { BarBackgroundColor = Color.FromHex(#SomeHex), BarTextColor = Color.Red};

BarTextColor = Color.Red 产生以下输出:

enter image description here

相关问题