在我们的应用程序中,我们使用以下代码设置导航栏和工具栏颜色。在iOS 8.x中,这工作正常。最近,我使用iOS 7.x测试了该应用程序,但没有显示颜色。条是透明的,文本是白色的(所以这有效...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UIToolbar appearance] setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];
[[UIToolbar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
[UIColor clearColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset,
[UIFont boldSystemFontOfSize:19.0], NSFontAttributeName,
nil]];
我希望有人能解释我如何解决这个问题。设置条形背景颜色对我来说不是解决方案,因为我会使用透明度。
此问题的解决方案是在iOS 7的弹出的ViewController中再次手动设置颜色值。
self.navigationController.toolbar.barStyle = UIBarStyleBlackTranslucent;
[self.navigationController.toolbar setTintColor:[UIColor whiteColor]];
[self.navigationController.toolbar setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:255.0/255.0 green:167.0/255.0 blue:0.0/255.0 alpha:1.0]];