2012-04-21 71 views
0

在我的应用程序中,我有选项卡栏控制器。我想要改变标签栏图像的默认颜色,即默认的蓝色。当它选择ios时更改tabbar图像颜色

请注意:我不想更改标签栏的背景颜色,但只选择默认蓝色中选定的标签栏项目的颜色。 这里是我的代码:

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

我在这里看到了许多问题,搜索互联网为好。有人建议私人API,我不感兴趣。有些人说当选项卡被选中时会放置自定义图像。

请建议我这样做的正确方法。

在此先感谢

回答

1

好像你需要

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

注:只与iOS> = 5

+1

工程我添加了**注**。希望你不会介意 – 2012-09-21 17:39:49

0

//设置的TabBar成图像

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

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