我想在导航栏中显示白色文字,但只要我有白色字体代码,我仍然会将其设为黑色。
let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController?.navigationBar.titleTextAttributes = titleDict
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 20)]
我试过
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName:UIColor.whiteColor()]
但没有工作
答案 0 :(得分:7)
似乎每次设置titleTextAttributes
时都要覆盖更改。尝试同时设置所有属性:
self.navigationController?.navigationBar.titleTextAttributes = [
NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 20),
NSForegroundColorAttributeName: UIColor.whiteColor()
]