iOS PopoVer NavigationBar不显示BarTintColor

时间:2015-04-28 08:35:05

标签: uinavigationbar uitoolbar tint bartintcolor

在我们的应用中,我们使用以下代码设置导航栏和工具栏颜色。使用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]];

我希望有人能解释我如何解决这个问题。设置条形背景颜色对我来说不是解决方案,因为我会使用透明度。

1 个答案:

答案 0 :(得分:0)

此问题的解决方案是在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]];