我试图改变这样的标题颜色,但它没有效果。
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
也许导航栏样式是黑色的问题?
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
答案 0 :(得分:0)
使用UITextAttributeTextColor
而不是NSForegroundColorAttributeName
作为密钥,它将起作用:)
答案 1 :(得分:0)
试试这个:
self.navigationItem.title = @"The title";
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];
答案 2 :(得分:-1)
尝试使用控制器的navigationBar实例
UIFont* font = kRobotoMedium(21));
[controller.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:font}];