Ios 类型';NSAttributedStringKey';(aka';NSString';)没有成员';foregroundColor';

Ios 类型';NSAttributedStringKey';(aka';NSString';)没有成员';foregroundColor';,ios,nsattributedstring,swift4.1,nsattributedstringkey,Ios,Nsattributedstring,Swift4.1,Nsattributedstringkey,下面是上述问题的代码行。 此问题出现在Swift 4.1中 let textAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white] navigationController?.navigationBar.titleTextAttributes = textAttributes 我已通过替换属性字符串的键修复了此问题 以下是我的更新代码: let textAttributes = [NSForegroundColorA

下面是上述问题的代码行。 此问题出现在
Swift 4.1

let textAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
navigationController?.navigationBar.titleTextAttributes = textAttributes

我已通过替换属性字符串的键修复了此问题

以下是我的更新代码:

let textAttributes = [NSForegroundColorAttributeName : UIColor.white]
navigationController?.navigationBar.titleTextAttributes = textAttributes

我已通过替换属性字符串的键修复了此问题

以下是我的更新代码:

let textAttributes = [NSForegroundColorAttributeName : UIColor.white]
navigationController?.navigationBar.titleTextAttributes = textAttributes