在使用 Swift 3.2 的 macOS 项目中,我正在尝试设置 UITextView 的前景色。
let placeHolderTitleString: NSAttributedString = NSAttributedString(string: "Enter text here", attributes: [NSAttributedStringKey.foregroundColor : NSColor.gray]) // error
我得到的错误是这样的:
类型“NSAttributedStringKey”(又名“NSString”)没有成员“foregroundColor”
相同的代码在 Swift 4.0 项目中运行良好。
我正在尝试根据我为 iOS Swift 4 Conversion error - NSAttributedStringKey: Any找到的一些答案修改代码,但我继续收到错误。有没有办法在不将项目更新到 Swift 4 的情况下解决这个问题?