iosuitabbaruicolortintcolorbartintcolor

UITabBar Selected Item Tint Color


I'm working on an UITabBar-Application.

I want to change the selected Item Color with

[[UITabBar appearance] setTintColor:[UIColor redColor]]

This works, until I want to set the Background Color of the TabBar with

[[UITabBar appearance] setBarTintColor:[UIColor blueColor]]

Then the Bar is blue, but the highlighted Items are grey.

[[UITabBar appearance] setBackgroundColor:[UIColor blueColor]]

has no effect. Any Idea? Thank you very much!


Solution

  • Your code, that you've posted, seems to be working. You can do it with images too. Try this:

    [tabBarItem1 setImage:[[UIImage imageNamed:@"home.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [tabBarItem1 setSelectedImage:[[UIImage imageNamed:@"home_selected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    // Change the tab bar background
    UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"];
    [[UITabBar appearance] setBackgroundImage:tabBarBackground];
    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected.png"]];