【问题标题】:How to set the Navigation Bar Color of the Tab Bar Configure Menu如何设置标签栏配置菜单的导航栏颜色
【发布时间】:2010-11-27 02:43:33
【问题描述】:

删除了无效的 ImageShack 链接

如您所见,我需要更改的视图是提供的用于自定义标签栏顺序的视图。我想更改导航栏的颜色(显示“Konfigurieren”,意思是“配置”),我已经知道如何更改“更多”-导航控制器的颜色,但不是这个。有人可以帮我吗?

【问题讨论】:

  • 是的。我也想知道。我已经尝试了几天,但我无法让它工作..
  • 我们看不到,真的,因为您的图片链接似乎已损坏。如果您仍有原始图像,请将其重新上传到 stack.imgur,或者只是编辑您的问题以使其在没有图像的情况下工作。谢谢。

标签: iphone objective-c uitabbar tabbar


【解决方案1】:

我认为您正在寻找的是这个(在创建导航控制器时执行,通常在您的应用委托中):

UINavigationController *navigationController;
...
navigationController.navigationBar.tintColor = [UIColor blackColor];

【讨论】:

    【解决方案2】:

    使用 int AppDelegate

    tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
    

    【讨论】:

    • 我不知道为什么这个答案被接受:它只改变了“更多”标签导航栏的色调(问题作者说他们已经做到了),而不是来自“自定义”模式视图控制器。 user486217 的回答符合要求。
    【解决方案3】:

    它肯定会工作! :-)

    self.navigationController.navigationBar.tintColor  = [UIColor blackColor];
    

    【讨论】:

    • 简单但很好的答案!谢谢。
    【解决方案4】:

    我能够像这样更改配置导航栏的颜色:

    1. 创建一个继承自 UITabBarController 的新类。
    2. 实现这个方法:

      -(void)beginCustomizingTabBar:(id)sender
      {
          [super beginCustomizingTabBar:sender];
      
          // Get the new view inserted by the method called above
          id modalViewCtrl = [[[self view] subviews] objectAtIndex:1];
      
          if([modalViewCtrl isKindOfClass:NSClassFromString(@"UITabBarCustomizeView")] == YES)
          {
              UINavigationBar* navBar = [[modalViewCtrl subviews] objectAtIndex:0];
      
              [navBar setBarStyle:UIBarStyleBlackTranslucent];
              [navBar setTranslucent:YES];
          }
      }
      

    【讨论】:

      【解决方案5】:

      可以更简单(在标签栏委托中使用):

      - (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers {
      id modalViewCtrl = [[[tabBarController view] subviews] objectAtIndex:1];  
      if([modalViewCtrl isKindOfClass:NSClassFromString(@"UITabBarCustomizeView")] == YES)
          ((UINavigationBar*)[[modalViewCtrl subviews] objectAtIndex:0]).tintColor = [UIColor redColor];
      }
      

      【讨论】:

        【解决方案6】:

        根据 user486217 给出的答案,这可能更具防御性:

        id modalViewCtrl = [controller.view.subviews objectAtIndex:1]; if([modalViewCtrl isKindOfClass:NSClassFromStrin(@"UITabBarCustomizeView")] == YES) { id navigationBar = [[modalViewCtrl 子视图] objectAtIndex:0]; if ([navigationBar isKindOfClass:[UINavigationBar class]]) { ((UINavigationBar*)navigationBar).tintColor = [UIColor redColor]; } }}

        【讨论】:

          【解决方案7】:

          有一种简单的方法可以更改所有导航栏样式,而不是单独更改每个样式。

          [[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
          

          只需在您的一个初始视图中设置此代码即可。这样,您的更多导航控制器和配置导航控制器(在更多导航控制器中单击“编辑”后出现)获得不同的样式。

          像这样,您可以将其颜色更改为其他颜色或更改背景图像。

          希望这会有所帮助。

          【讨论】:

            【解决方案8】:

            如果您正在寻找标准颜色(灰色、黑色、白色),您可以在 xCode 5 中设置这些值。选择整个视图控制器,然后选择属性检查器。在属性下,您会在“顶部栏”旁边找到一个下拉菜单。您可以在此处为导航栏控制器选择各种颜色和不透明度设置。

            下面概述了一些屏幕截图。希望这会有所帮助!

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2018-12-23
              • 1970-01-01
              • 1970-01-01
              • 2018-10-25
              相关资源
              最近更新 更多