2012-04-27 57 views
3

我有我的界面完全布局与故事板(包括UITabBarController和所有相应的意见)。setFinishedSelectedImage:withFinishedUnselectedImage:+ Storyboards

现在来定制选项卡栏。由于我的图标已经设置为正确的颜色,因此我不能使用[[UITabBar appearance] setTintColor:](它只是看起来不对)。

原来我应该在特定的UITabBarItem上使用setFinishedSelectedImage:withFinishedUnselectedImage:

是否有可能从AppDelegate(我的全局定制发生的其余部分)使用此方法? AppDelegate如何知道要定位哪个UITabBar?

如果相反,我应该从定制每个UIViewController中每个UITabBarItem,我该如何引用UITabBar(或“根视图控制器”?),然后具体的项目从UIViewController的?

任何帮助将不胜感激。 谢谢!

+0

中的TabBar项删除图像既然你报上我的回答您的问题作为已接受的回答,请使用复选标记按钮将其作为正确答案接受。谢谢。 – DTs 2014-02-21 00:59:21

回答

2

在你UIViewController实例viewDidLoad,你可以做

[self.tabBarItem setFinishedSelectedImage: withFinishedUnselectedImage:] 
1

试试这个

- (id)initWithCoder:(NSCoder *)aDecoder 
{ 
    self = [super initWithCoder:aDecoder]; 

    if (self) { 
     [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"t1s"] withFinishedUnselectedImage:[UIImage imageNamed:@"t1"]]; 
     [self.tabBarItem setTitle:@"Title"]; 
    } 

    return self; 
} 

此外,从故事板视图

+0

它的工作原理,谢谢! – Shmidt 2013-06-26 17:27:54

+0

我建议在'viewDidLoad:'中设置完成的图像,因为如果以编程方式加载ViewController,'initWithCoder:'将不会执行。虽然这个特定的问题明确引用了Interface Builder,但其他用户阅读这个问题可能并不是这样。 – DTs 2013-12-02 01:04:34

相关问题