我正在尝试使用NavigationController
更改iOS
中Xamarin
的标题文字颜色,但我无法更改它。
有人可以帮助我实现它吗?
答案 0 :(得分:17)
我试过这种方式,它对我有用。
var navigationBar = NavigationController.NavigationBar;
navigationBar.SetTitleTextAttributes(new UITextAttributes() { TextColor = UIColor.White });
Sathish所在
编辑:
UINavigationBar
不再使用方法SetTitleTextAttributes
。相反,您必须将TitleTextAttributes
属性设置为UIStringAttributes
属性,如下所示:
this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = UIColor.White };
答案 1 :(得分:4)
这篇文章很老了,但我认为这就是你所需要的:
this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes() {
ForegroundColor = UIColor.White
};
适用于xamarin Unified API
答案 2 :(得分:2)
您无法直接更改它。只能通过外观或使用您自己的视图作为标题。以下是在Xamarin.iOS中使用外观的解决方案:
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
TextColor = UIColor.Purple
});
答案 3 :(得分:1)
titleTextAttributes 显示栏标题文本的属性。
@property(nonatomic, copy) NSDictionary *titleTextAttributes
讨论 您可以使用NSString UIKit Additions Reference中描述的文本属性键为文本属性字典中的标题指定字体,文本颜色,文本阴影颜色和文本阴影偏移。