2017-03-16 82 views
0

我試圖改變標題顏色,但它沒有效果。如何更改導航欄標題顏色?

NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil]; 
[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes]; 

也許導航欄風格是黑色的問題?

self.navigationController.navigationBar.barStyle = UIBarStyleBlack; 
+0

試試這個http://stackoverflow.com/a/621185/7250862 –

+0

你檢查了我的updat ed ans? –

回答

-1

嘗試使用控制器的導航欄

UIFont* font = kRobotoMedium(21)); 
[controller.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:font}]; 
+0

我設置了相同的設置,但沒有任何效果。 –

+0

檢查backgroundColor,tintcolor(查看顏色組合)和半透明屬性。 – NSPiyush

0

使用UITextAttributeTextColor,而不是NSForegroundColorAttributeName的實例爲重點,它會工作:)

0

試試這個:

self.navigationItem.title = @"The title"; 
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];