ios13 中的 UITextfield 的 PlaceholderColor 未设置为 PlaceHolderLabel

PlaceholderColor not set to PlaceHolderLabel for UITextfield in ios13

self.setValue(placeHolderColor, forKeyPath: "_placeholderLabel.textColor")

在 ios13 中 crashed.how 将 placeholderColor 设置为 placeholderLabel in swift5 for ios13 in xcode11.

使用 attributedPlaceholder 设置 color 如下,

let colorAttrbs: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.red]
textField.attributedPlaceholder = NSAttributedString(string: "placeholder", attributes: colorAttrbs)