如何在iOS 7上更改UINavigationBar中文本的颜色?

6
如何在iOS 7中更改UINavigationBar文本颜色?我想让它变成白色而不是黑色。

1
请查看 UINavigationBar textTitleAttributes - rmaddy
1
我之前回答过类似的问题:https://dev59.com/n2Mk5IYBdhLWcg3w0hM-#18934411 - RFG
1个回答

13
如果您接受全局更改,可以将以下代码放在您的应用委托中:
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor, nil];
[[UINavigationBar appearance] setTitleTextAttributes:attributes];

3
为什么要使用旧语法?@{UITextAttributeTextColor: [UIColor whiteColor]} - Brian Nickel
1
在iOS 7中,UITextAttributeTextColor似乎已被弃用。 - Nicolas Miari
10
在iOS 7及其以后版本中,使用NSForegroundColorAttributeName代替UITextAttributeTextColor。 - Andrew Zimmer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接