objective-c 如何设置标签栏配置菜单的导航栏颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1404197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set the Navigation Bar Color of the Tab Bar Configure Menu
提问by gabtub
removed dead ImageShack link
删除了无效的 ImageShack 链接
As you can see the view I need to change is the provided view to customize the tabbar order. 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. Can anybody help me with that?
如您所见,我需要更改的视图是提供的用于自定义标签栏顺序的视图。我想更改导航栏的颜色(显示“Konfigurieren”,意思是“配置”),我已经找到了如何更改“更多”导航控制器的颜色,但不是这个。有人可以帮我吗?
采纳答案by Saqib Saud
Use int AppDelegate
使用 int AppDelegate
tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
回答by Zoran Simic
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];
回答by Developer
Its Surely gonna work! :-)
它肯定会工作!:-)
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
回答by Alex
Can be easier (use in tab bar delegate):
可以更容易(在标签栏委托中使用):
- (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];
}
回答by fabioalmeida
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.
希望这可以帮助。
回答by Eisen Montalvo
I was able to change the color of the Configure NavBar like this:
我能够像这样更改配置导航栏的颜色:
- Create a new class that inherits from UITabBarController.
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]; } }
- 创建一个继承自 UITabBarController 的新类。
实现这个方法:
-(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]; } }
回答by diadyne
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];
}
}}
回答by preynolds
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. 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.
如果您正在寻找标准颜色(灰色、黑色、白色),您可以在 xCode 5 中设置这些值。选择整个视图控制器,然后选择属性检查器。在属性下,您会在“顶栏”旁边找到一个下拉菜单。在那里您可以为导航栏控制器选择各种颜色和不透明度设置。
Outlined below are a few screenshots. Hope this helps!
下面概述了一些屏幕截图。希望这可以帮助!





