2012-05-07 52 views
0

有一個的UITabBarController如何更改UITabbarViewController的navigationBar的顏色?

- (void)getToMCGatherViewController 
{ 
    mCGatherViewController = [[MCGatherViewController alloc] initWithNibName:@"MCGatherViewController" bundle:nil]; 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mCGatherViewController]; 
    navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentModalViewController:navigationController animated:YES]; 
    [navigationController release]; 
} 

在.h文件:

@interface MCGatherViewController : UITabBarController 

在.m文件。我想改變視圖的導航條的顏色條形碼

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.navigationController.navigationBar.tintColor=[UIColor greenColor]; 
} 

它根本不起作用。

幫我解決這個問題,提前謝謝!

+0

你的問題很複雜,請澄清你想要什麼? – vishiphone

回答

2

剛過

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mCGatherViewController]; 
在getToMCGatherViewController方法

添加

[navigationController.navigationBar setTintColor:[UIColor greenColor]]; 

+0

Thx男人,你的答案真的很有幫助!謝謝 ! – jxdwinter

+0

接受答案,如果它爲你工作..快樂編碼:) –

0

只需編輯您的代碼,並嘗試我認爲這將適用於您。

mCGatherViewController = [[MCGatherViewController alloc] initWithNibName:@"MCGatherViewController" bundle:nil]; 
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mCGatherViewController]; 
navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

[self.view addSubview:nav.view]; 

然後你改變你的導航欄的色調顏色。