Search code examples
iosios7colorstabs

Change tab bar tint color on iOS 7 and later


Is there a way to change the tint of a tab bar on iOS 7 from the default white with blue icons to another color tint with different color buttons?


Solution

  • Try the below:

    [[UITabBar appearance] setTintColor:[UIColor redColor]];
    [[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];
    

    To tint the non active buttons, put the below code in your VC's viewDidLoad:

    UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:0];
    
    UIImage *unselectedImage = [UIImage imageNamed:@"icon-unselected"];
    UIImage *selectedImage = [UIImage imageNamed:@"icon-selected"];
    
    [tabBarItem setImage: [unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [tabBarItem setSelectedImage: selectedImage];
    

    You need to do this for all the tabBarItems, and yes I know it is ugly and hope there will be cleaner way to do this.

    Swift:

    UITabBar.appearance().tintColor = UIColor.red
    
    tabBarItem.image = UIImage(named: "unselected")?.withRenderingMode(.alwaysOriginal)
    tabBarItem.selectedImage = UIImage(named: "selected")?.withRenderingMode(.alwaysOriginal)