如何解决Xamarin.forms NavigationBar标题为IOS设置文本颜色
我正在使用xamarin.forms应用程序,我想更改我的标题颜色。我为android添加并正常工作,但对于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();
,但标题颜色为Black
。有什么建议吗?
解决方法
在此处的 TintColor 属性中更改导航栏的背景颜色
BarTintColor 属性会影响
的颜色- 后退指示器图像
- 按钮标题
- 按钮图像
因此,在您的情况下,设置标题的 TextColor 可以调用以下代码。
UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes
{
ForegroundColor = UIColor.White
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。