Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Xamarin更改iOS中NavigationController的标题文本颜色_Ios_Uinavigationcontroller_Xamarin.ios_Xamarin - Fatal编程技术网

如何使用Xamarin更改iOS中NavigationController的标题文本颜色

如何使用Xamarin更改iOS中NavigationController的标题文本颜色,ios,uinavigationcontroller,xamarin.ios,xamarin,Ios,Uinavigationcontroller,Xamarin.ios,Xamarin,我正在尝试使用Xamarin更改iOS中NavigationController的标题文本颜色,但我无法更改它 有人能帮我实现吗?titleTextAttributes 显示栏标题文本的属性 @property(nonatomic, copy) NSDictionary *titleTextAttributes 讨论 您可以使用NSString UIKit Additions Reference中描述的文本属性键,在文本属性字典中为标题指定字体、文本颜色、文本阴影颜色和文本阴影偏移量。您不能直

我正在尝试使用
Xamarin
更改
iOS
NavigationController
的标题文本颜色,但我无法更改它

有人能帮我实现吗?

titleTextAttributes 显示栏标题文本的属性

@property(nonatomic, copy) NSDictionary *titleTextAttributes
讨论
您可以使用NSString UIKit Additions Reference中描述的文本属性键,在文本属性字典中为标题指定字体、文本颜色、文本阴影颜色和文本阴影偏移量。

您不能直接更改它。仅通过外观或使用自己的视图作为标题。以下是在Xamarin.iOS中使用外观的解决方案:

UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
  TextColor = UIColor.Purple
});

我试着用这种方法,它对我有效

        var navigationBar = NavigationController.NavigationBar;
        navigationBar.SetTitleTextAttributes(new UITextAttributes() { TextColor = UIColor.White });
萨提斯

编辑:

UINavigationBar
不再具有方法
SetTitleTextAttributes
。相反,必须将
TitleTextAttributes
属性设置为
UIStringAttributes
属性,如下所示:

this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = UIColor.White };

这篇文章很旧,但我认为这是你需要的:

this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes() {
            ForegroundColor = UIColor.White
        };

曾为xamarin统一API工作过

我认为这不再有效
UINavigationBar
没有
SetTitleTextAttributes
方法,而是需要设置为
UIStringAttributes
对象的属性
TitleTextAttributes
。见@megaKertz答案<代码>this.NavigationController.NavigationBar.TitleTextAttributes=new-UIStringAttributes(){ForegroundColor=UIColor.White}