【发布时间】:2018-02-26 05:23:09
【问题描述】:
我无法更改导航栏上的提示颜色。我在viewDidLoad 中尝试了下面的代码,但没有任何反应。
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
我错过了什么吗?上面的代码错了吗?
【问题讨论】:
-
试试
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white] -
在 swift 4 中,
titleTextAttributes的类型为[NSAttributedStringKey: Any]?。NSForegroundColorAttributeName是一个字符串,所以这种方式不会构建。
标签: ios swift cocoa-touch uikit uinavigationbar