删除了死亡的ImageShack链接

正如您所看到的,我需要更改的视图是用于自定义tabbar顺序的提供视图。我想要改变导航栏的颜色(显示“Konfigurieren”,这意味着“配置”),我已经找到了如何改变“更多” - 导航控制器的颜色,但不是这个。有人可以帮我吗?

有帮助吗?

解决方案

使用int AppDelegate

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

其他提示

我认为您正在寻找的是(当您创建导航控制器时,通常在您的应用代理中):

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

它肯定会起作用! :-)

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

可以更容易(在标签栏委托中使用):

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

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

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

只需在您的一个初始视图中设置此代码即可。有了这个,你的更多导航控制器和配置导航控制器(在更多导航控制器中点击“编辑”后出现)会得到不同的风格。

像这样你可以改变它的颜色或改变背景图像。

希望这有帮助。

我可以像这样更改配置NavBar的颜色:

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

基于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];
    }
}}

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

以下概述了一些截图。希望这有帮助!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top