Change UITabBar tint colors in the More menu

被刻印的时光 ゝ 提交于 2019-11-28 11:42:43
Ludovic

To do what you need, you should use images by creating UITabBarItem for each controller and add an image and a selected image.

See Apple Documentation about UITabBarItem

Otherwise looks here, from @Aaron Brager :

Edit after seing the full code First there is many mistakes in your project, assets should be in xcassets folder, in view didload write your code after the 'super viewDidLoad]', etc.

About your problem, in your viewDidLoad method in the FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // Your code start here, not before the super
    [[UITabBar appearance] setTintColor:[UIColor redColor]];

    // Get table view of more new viewController
    UITableView *view =(UITableView*)self.tabBarController.moreNavigationController.topViewController.view;

    view.tintColor = [UIColor redColor]; // Change the image color

    if ([[view subviews] count]) {
        for (UITableViewCell *cell in [view visibleCells]) {
            cell.textLabel.textColor = [UIColor redColor]; // Change the text color

        }
    }
}

This is the Swift version of Ludovic's answer.

Keep in mind that this version only changes the tint color, since the original answer did the text color change in a very hacky way. For changing it properly, you'd have to override moreNavigationController and its cellForRowAt function.

tabBarController?.tabBar.tintColor = .red

if let moreTableView = tabBarController?.moreNavigationController.topViewController?.view as? UITableView {
    moreTableView.tintColor = .red
}

to change color of this button

    moreNavigationController.navigationBar.tintColor = .white

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!