How to change Background color of UITabbar selected tab color to blue?

Ankit Vyas picture Ankit Vyas · Jul 7, 2012 · Viewed 12.9k times · Source

enter image description here

Hi, I wanted this kind of Tab Selection effect. Instead of Black Background it should be blue one.Is it possible that when i select any tab it should come up with blue background.Please guide me what should i do?I have tried so much but not getting any proper solution.Please suggest me what should i do?

Answer

KDaker picture KDaker · Jul 7, 2012

use the tintColor: property of UITabBar:

myTabBarController.tabBar.tintColor = [UIColor blueColor];

note this only works on iOS5.

EDIT:

oops! sorry i misunderstood your question. I thought you meant the background color of the whole tab bar.

For that you can add an image for background of the selection using selectionIndicatorImage property:

myTabBarController.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"myImage.png"];

hope this helps