gpt4 book ai didi

c# - 更改导航栏标题的颜色

转载 作者:行者123 更新时间:2023-11-28 18:32:43 24 4
gpt4 key购买 nike

我正在尝试使用 MonoTouchXamarin 中设置 UINavigationBar 的样式。在 UIViewController 的构造函数中,我尝试了以下操作:

//this.NavigationController.NavigationBar.TintColor = UIColor.Magenta;
UINavigationBar.Appearance.TintColor = UIColor.Yellow;

但如果我尝试在模拟器中运行它,则没有任何改变。我应该把这段代码放在哪里?如何使用 RGB 颜色(使用 UIColor.FromRGB (0, 127, 14)?)我的代码是否正确?

最佳答案

我的解决方案:

//AppDelegate.cs
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
public static UIStoryboard Storyboard = UIStoryboard.FromName ("MainStoryboard", null);
public static UIViewController initialViewController;

// ...
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
initialViewController = Storyboard.InstantiateInitialViewController () as UIViewController;

UINavigationBar.Appearance.SetTitleTextAttributes (
new UITextAttributes () { TextColor = UIColor.FromRGB (0, 127, 14) });

window.RootViewController = initialViewController;
window.MakeKeyAndVisible ();
return true;
}
}

关于c# - 更改导航栏标题的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25154379/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com