如何通过Swift更改UITextField的占位 rune 本颜色?我似乎无法访问占位符属性。谢谢
最佳答案
您可以使用属性字符串设置占位 rune 本。将颜色设置为attributes
属性。
textField.attributedPlaceholder = NSAttributedString(string:"placeholder text",
attributes:[NSForegroundColorAttributeName: UIColor.yellowColor()])
swift 5
textField.attributedPlaceholder = NSAttributedString(string:"placeholder text", attributes:[NSAttributedString.Key.foregroundColor: UIColor.yellow])