简体   繁体   English

如何设置标签栏配置菜单的导航栏颜色

[英]How to set the Navigation Bar Color of the Tab Bar Configure Menu

removed dead ImageShack link 删除了死的ImageShack链接

As you can see the view I need to change is the provided view to customize the tabbar order. 正如您所看到的,我需要更改的视图是提供的视图来自定义tabbar顺序。 I want to change the color of the navigation bar (displaying "Konfigurieren" which means "Configure"), I already found out how to change the color of the "More"-Navigation Controller, but not this one. 我想改变导航栏的颜色(显示“Konfigurieren”,意思是“配置”),我已经找到了如何更改“更多”导航控制器的颜色,但不是这个。 Can anybody help me with that? 任何人都可以帮助我吗?

I think what you are looking for is this (to do when you create your navigation controller, typically in your app delegate): 我认为您正在寻找的是(当您创建导航控制器时,通常在您的应用委托中):

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

使用int AppDelegate

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

Its Surely gonna work! 它肯定会工作! :-) :-)

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

Can be easier (use in tab bar delegate): 可以更容易(在tab bar委托中使用):

- (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];
}

There is an easy way to change all the navigation bar styles instead of changing each one separately. 有一种简单的方法可以更改所有导航栏样式,而不是分别更改每个样式。

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

Just set this code in one of your initial views. 只需在您的一个初始视图中设置此代码即可。 With this, your more navigation controller and the configuration navigation controller (that appears after clicking "Edit" in more navigation controller) get a different style. 有了这个,您的更多导航控制器和配置导航控制器(在更多导航控制器中单击“编辑”后出现)将获得不同的样式。

Like this you can change its color to a different one or change the background image. 像这样,您可以将其颜色更改为其他颜色或更改背景图像。

Hope this helps. 希望这可以帮助。

I was able to change the color of the Configure NavBar like this: 我能够改变配置NavBar的颜色,如下所示:

  1. Create a new class that inherits from UITabBarController. 创建一个继承自UITabBarController的新类。
  2. Implement this method: 实现此方法:

     -(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]; } } 

Building off of the answer given by user486217, this may be even more defensively-coded: 基于user486217给出的答案,这可能更具防御性编码:

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

If you are looking for the standard colors (Gray, Black, White), you can set these values within xCode 5. Select the entire view controller, and select the attributes inspector. 如果要查找标准颜色(灰色,黑色,白色),可以在xCode 5中设置这些值。选择整个视图控制器,然后选择属性检查器。 Under the attributes you will find a drop-down next to "Top Bar". 在属性下,您会在“顶栏”旁边找到一个下拉列表。 There you can select various setting for color and opacity for the navigation bar controller. 在那里,您可以为导航栏控制器选择各种颜色和不透明度设置。

Outlined below are a few screenshots. 下面列出的是一些截图。 Hope this helps! 希望这可以帮助!

在此输入图像描述

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM