1

我正在尝试设置所有标签栏的导航栏 UIBarStyleBlack。

我也可以通过以下方式为“更多”标签栏实现这一点:

tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;

问题是,当您单击其顶部的编辑按钮以自定义选项卡时,它会显示一个带有标准蓝色导航栏的新模式控制器,而我无法将其设置为 UIBarStyleBlack。

4

3 回答 3

3

该链接有一个稍微老套的解决方案,其中涉及监听模式视图何时出现。

使用 moreNavigationController 着色乐趣

直到 iOS5+ 使我们能够以更清洁的方式来做这件事。

于 2011-12-13T02:10:20.490 回答
2

Swift - 自定义标签栏 -> 更多菜单 -> 编辑视图(导航栏和内容视图)。

override func tabBar(_ tabBar: UITabBar, willBeginCustomizing items: [UITabBarItem]) {
    for (index, subView) in view.subviews.enumerated() {
        subView.backgroundColor = UIColor.black
        if index == 1 {
            subView.tintColor = UIColor.green
            for customSubView in subView.subviews {
                if let navBar = customSubView as? UINavigationBar {
                    navBar.isTranslucent = false
                    navBar.barTintColor = UIColor.black
                    navBar.tintColor = .white
                }
            }
        }
    }
}

这对我有用。

于 2018-10-23T08:23:39.933 回答
0

子类化UITabBarController并覆盖这些方法:

- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed {
    self.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
}

- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray<UITabBarItem *> *)items {
    self.moreNavigationController.navigationBar.barStyle = UIBarStyleDefault;
}
于 2016-08-04T08:20:45.660 回答