Ios 如何更改导航栏的背景颜色和导航文本颜色
我希望导航栏的背景色为黑色,导航栏上的文本为白色 在我的模拟器上,一切看起来都很好,如下所示: 然而,当我在实际设备w/7.1上测试它时,即使导航栏的背景颜色是橙色,屏幕的标题也是黑色的 这就是我在我的应用程序委托中所做的:Ios 如何更改导航栏的背景颜色和导航文本颜色,ios,ios7,rubymotion,Ios,Ios7,Rubymotion,我希望导航栏的背景色为黑色,导航栏上的文本为白色 在我的模拟器上,一切看起来都很好,如下所示: 然而,当我在实际设备w/7.1上测试它时,即使导航栏的背景颜色是橙色,屏幕的标题也是黑色的 这就是我在我的应用程序委托中所做的: @window.rootViewController = UINavigationController.alloc.initWithRootViewController(main_controller) @window.rootViewController.navigati
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(main_controller)
@window.rootViewController.navigationBar.barTintColor = '#DF533B'.to_color
@window.rootViewController.navigationBar.translucent = true
@window.rootViewController.navigationBar.tintColor = UIColor.whiteColor
@window.rootViewController.navigationBar.setTitleTextAttributes({
UITextAttributeTextColor => UIColor.whiteColor
})
我的部署_目标是7.0,app.sdk_版本是7.1
我是否应该将此代码放入我所有控制器的viewDidLoad中?不熟悉RubyMotion,但您应该使用UIAppearance代理:
[[UINavigationBar appearance] setBarTintColor:[self navBarColor]];
[[UINavigationBar appearance] setTintColor:[self navBarTitleColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [self navBarTitleColor], NSFontAttributeName : [self titleFont]}];
您应该在将主窗口加载到AppDelegate中之前执行此操作。要添加到Moby的答案中(我觉得答案是正确的),请确保将其添加到didFinishLaunchingWithOptions中,以供您的AppDelegate使用