Xamarin.ios 在monotouch中设置导航栏颜色
我正在尝试用MonoTouch编写一个应用程序。我需要设置导航栏的背景色。我想把它调成橙色。这似乎是一项容易的任务,但我似乎无法让它发挥作用。目前,我正在AppDelegate.cs文件中执行以下操作:Xamarin.ios 在monotouch中设置导航栏颜色,xamarin.ios,uinavigationbar,Xamarin.ios,Uinavigationbar,我正在尝试用MonoTouch编写一个应用程序。我需要设置导航栏的背景色。我想把它调成橙色。这似乎是一项容易的任务,但我似乎无法让它发挥作用。目前,我正在AppDelegate.cs文件中执行以下操作: this.window = new UIWindow (UIScreen.MainScreen.Bounds); this.rootNavigationController = new UINavigationController(); UIColor backgroundColor =
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;
但是,导航栏颜色仍然是默认颜色。如何设置导航栏的背景色?尝试更改“淡色”和“半透明”属性。尝试更改“淡色”和“半透明”属性。您可以按照Rob使用“淡色”属性所述,在特殊情况下执行此操作:
this.rootNavigationController.NavigationBar.TintColor = UIColor.Orange;
或者,您也可以使用iOS 5中的UIAppearance代理一次为所有UINavigationBars设置TintColor。这通常在AppDelegate中的DidFinishLaunchingWithOptions方法附近完成:
UINavigationBar.Appearance.TintColor = UIColor.Orange;
您可以查看Apple文档以了解更多详细信息和实施限制:
您可以使用TintColor属性在特定的基础上执行此操作:
this.rootNavigationController.NavigationBar.TintColor = UIColor.Orange;
或者,您也可以使用iOS 5中的UIAppearance代理一次为所有UINavigationBars设置TintColor。这通常在AppDelegate中的DidFinishLaunchingWithOptions方法附近完成:
UINavigationBar.Appearance.TintColor = UIColor.Orange;
您可以查看Apple文档以了解更多详细信息和实施限制:
以下代码不会达到您期望的效果:
newuicolor(74151223255)
,因为.ctor接受的是float
s,而不是字节。如果要使用byte
s创建颜色,请尝试使用UIColor.FromRGBA
。以下代码不会达到预期效果:new UIColor(74151223255)
,因为.ctor接受float
s,而不是字节。如果要使用byte
s创建颜色,请尝试使用UIColor.FromRGBA
。似乎并非monotouch中的所有视图都支持TintColor属性。似乎并非monotouch中的所有视图都支持TintColor属性。