ios - 类型 'NSAttributedStringKey'(又名 'NSString')没有成员 'foregroundColor'

标签 ios nsattributedstring swift4.1 nsattributedstringkey

下面是针对上述问题的代码行。 此问题发生在 Swift 4.1 中。

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

最佳答案

我已经通过替换属性字符串的键解决了这个问题。

这是我更新后的代码:

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

关于ios - 类型 'NSAttributedStringKey'(又名 'NSString')没有成员 'foregroundColor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50325873/

相关文章:

ios - 将 SDWebImage 集成到 TVOs 项目

ios - 这个 Objective-C 正则表达式有什么问题?

ios - UIImageView 中突出显示的图像到底是什么?

ios - 没有名为 AKNode/AKToggleable 的类型或协议(protocol)

iphone - 在 Core Graphics 和 CorePlot 中用 'raised effect'/gradient 画一条线

ios - 在 Swift 中,如何更改字符串的一部分的属性?

ios - 如何从一侧弯曲或扭曲 UILabel 文本

ios - 在我的应用程序中点击 UITextField 时,UIKeyboard 不出现

ios - 从私有(private) pod 的 Assets 目录中加载图像

Firebase 中的 iOS Crashlytics 在 Swift 4.1 中不起作用