2017-03-16 85 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];