Mann
Mann

Reputation: 5507

changing tabbar image color when it selected ios

In my application i have Tab bar Controller. I want to change default color of Tab bar image when it get selected i.e. default blue color.

Please note: I do not want to change background color of Tab bar but only the color of selected tabbar item when it selected from default blue color. Here is my code:

 NSArray *tabObjects=[NSArray arrayWithObjects:nav,video,about, nil];
 tabView=[[UITabBarController alloc] init];   
 tabView.viewControllers=tabObjects;

I have seen many questions here and searched internet as well. Some people suggest private API's that i am not interested. Some people say to put custom image when tab get selected.

Please suggest me proper way to do so.

Thanks in advance

Upvotes: 0

Views: 1321

Answers (2)

Rain
Rain

Reputation: 124

//set the tabbar into image

[[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"menubar"]];

//set the color of selected  image color
[[[self tabBarController] tabBar] setSelectedImageTintColor:[UIColor redColor]];

Upvotes: 0

Pavel
Pavel

Reputation: 421

Seems like you need

[[UITabBar appearance] setSelectedImageTintColor:[UIColor purpleColor]];

Note: Works only with iOS >=5

Upvotes: 1

Related Questions