在monotouch中设置导航栏颜色

Vil*_*ger 1 uinavigationbar xamarin.ios

我正在尝试使用MonoTouch编写应用程序.我需要设置导航栏的背景颜色.我想将它设置为橙色.这似乎是一件容易的事,但我似乎无法让它发挥作用.目前,我在AppDelegate.cs文件中执行以下操作:

this.window = new UIWindow (UIScreen.MainScreen.Bounds);
this.rootNavigationController = new UINavigationController();   

UIColor backgroundColor = new UIColor(74, 151, 223, 255);
this.rootNavigationController.NavigationBar.BackgroundColor = UIColor.Orange;
Run Code Online (Sandbox Code Playgroud)

但是,导航栏颜色仍然是默认颜色.如何设置导航栏的背景颜色?

Anu*_*nuj 6

您可以在临时的基础上执行此操作,因为Rob使用TintColor属性描述:

this.rootNavigationController.NavigationBar.TintColor = UIColor.Orange;
Run Code Online (Sandbox Code Playgroud)

或者,您也可以使用iOS 5中的UIAppearance代理一次为所有UINavigationBars设置TintColor.这通常在AppDelegate中的DidFinishLaunchingWithOptions方法附近进行:

UINavigationBar.Appearance.TintColor = UIColor.Orange;
Run Code Online (Sandbox Code Playgroud)

您可以查看Apple文档以获取更多详细信息和实施限制:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html