Xamarin.forms导航栏标题设置IOS的文本颜色

Xamarin.forms导航栏标题设置IOS的文本颜色,xamarin.forms,xamarin.ios,navbar,Xamarin.forms,Xamarin.ios,Navbar,我正在使用xamarin.forms应用程序,我想更改标题颜色。我添加了安卓系统,工作正常,但IOS系统不知道如何改变。我添加了状态栏设计 public override void OnActivated(UIApplication uiApplication) { if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0)) { //

我正在使用xamarin.forms应用程序,我想更改标题颜色。我添加了安卓系统,工作正常,但IOS系统不知道如何改变。我添加了状态栏设计

        public override void OnActivated(UIApplication uiApplication)
        {
 
            if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
            {
                // If VS has updated to the latest version , you can use StatusBarManager , else use the first line code
                // UIView statusBar = new UIView(UIApplication.SharedApplication.StatusBarFrame);
                UIView statusBar = new UIView(UIApplication.SharedApplication.KeyWindow.WindowScene.StatusBarManager.StatusBarFrame);
                statusBar.BackgroundColor = Color.FromHex("07987f").ToUIColor(); 
                statusBar.TintColor= Color.FromHex("07987f").ToUIColor();    
                
                UIApplication.SharedApplication.KeyWindow.AddSubview(statusBar);
            }
            else
            {
                UIView statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
                if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
                {
                    statusBar.BackgroundColor = Color.FromHex("07987f").ToUIColor(); 
                    statusBar.TintColor= Color.FromHex("07987f").ToUIColor();
                }
            }
            base.OnActivated(uiApplication);
        }
状态栏、导航栏设计也可以:

            UINavigationBar.Appearance.BarTintColor = Color.FromHex("07987f").ToUIColor();
            UINavigationBar.Appearance.TintColor = Color.White.ToUIColor();
            

但是标题颜色是黑色。有什么建议吗?

在这里TintColor属性更改导航栏的背景色

BarTintColor属性影响

  • 后指示器图像
  • 按钮标题
  • 按钮图像
因此,在您的情况下,设置标题的TextColor,您可以调用以下代码

UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes
{
    ForegroundColor = UIColor.White
};

尝试设置
UINavigationBar.Appearance.TitleTextAttributes=newuistringattributes{ForegroundColor=UIColor.White}@LucasZhang MSFT谢谢。我首先编写了UINavigationBar.Appearance.TitleTextAttributes.ForegroundColor=Color.White.ToUIColor();并获取NullObject异常。现在工作顺利了,我会把答案贴出来,你能接受吗?这将帮助更多人:)@LucasZhang MSFTyes@LucasZhang-微软接受