0

在我的应用程序中,我有标签栏控制器。我想在被选中时更改标签栏图像的默认颜色,即默认蓝色。

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

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

我在这里看到了很多问题,也搜索了互联网。有些人建议我不感兴趣的私有 API。有人说在选择选项卡时放置自定义图像。

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

提前致谢

4

2 回答 2

1

好像你需要

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

注意:仅适用于 iOS >=5

于 2012-05-19T08:59:28.360 回答
0

//设置标签栏为图片

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

//set the color of selected  image color
[[[self tabBarController] tabBar] setSelectedImageTintColor:[UIColor redColor]];
于 2013-07-03T08:53:28.137 回答