如何更改UITabBarItem中的文本颜色?

时间:2011-04-28 07:58:03

标签: objective-c uicolor uitabbaritem

在UITabBarItem中如何更改文本的颜色。默认情况下,文本出现在whiteColor中。我想改成黑色,怎么做?

1 个答案:

答案 0 :(得分:0)

  

在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;
}