xCode TabBarItem标题和图标颜色

时间:2012-01-22 16:53:44

标签: objective-c xcode uitabbarcontroller uitabbar

我似乎无法更改Tabbaritem标题的颜色和未突出显示的图标。我希望标题和图标的颜色从灰色变为另一种颜色。

2 个答案:

答案 0 :(得分:2)

  

在AppDelegate.m中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
return YES;
}
  

用于更改文本颜色viewController.m

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor],UITextAttributeTextColor,nil] forState:UIControlStateNormal];
}
return self;
}

答案 1 :(得分:0)

iOS v5.0提供了自定义tabbaritem的方法;阅读此link

的文档