[英]ios - change navigation bar tint color of 'More' tab
我的UITabBar
有7個標簽。 iOS
自動將最后2個標簽分組為一個名為“更多”的標簽。 我為viewDidLoad
的7個選項卡設置了導航欄色調顏色,如下所示:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
如何為自動生成的“更多”標簽設置導航欄的顏色?
您可以訪問self.tabBarController.moreNavigationController
來獲取在用戶點擊“更多”選項卡欄項時出現的導航控制器。 現在,您可以執行修改和自定義。 例如,您可以更改其導航欄的樣式。 例:
UINavigationController* more = self.tabBarController.moreNavigationController;
more.navigationBar.barStyle = UIBarStyleBlack;
有關如何自定義在點擊更多選項卡欄項時顯示的內容的更多信息,請參閱我的書的以下部分:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
這行更改了導航欄的tintColor
。
從您的問題來看,我(當然還有其他人)似乎誤解了UITabBarController
作為UINavigationController
。
您可以在此處找到有關自定義UITabBarController
所有信息。
您需要在AppDelegate.m中更改UINavigationController的顏色
UIColor *navBarColor = [UIColor blackColor];
[[UINavigationBar appearance] setTintColor:navBarColor];
self.navigationController.navigationBar.tintColor = navBarColor;
嘗試外觀(可能在應用程序委托中的didfinishlaunchingwithoptions中)。
[[UITabBar appearance] setTintColor:[UIColor blackColor]];
[[UITabBarItem appearance] setTintColor:[UIColor blackColor]];
對於iOS 7,您可以通過將以下內容添加到AppDelegate中來更改導航欄的顏色,設置為非半透明(默認為是)並更改導航標題的顏色:
UINavigationController *moreController = _tabBarController.moreNavigationController;
moreController.navigationBar.barTintColor = [UIColor orangeColor];
moreController.navigationBar.translucent = NO;
moreController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
對於ios 8.0
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.