更改导航栏标题的颜色

测试

我想在样式UINavigationBarXamarinMonoTouch在的构造函数中,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;
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章