如何通过 Swift 更改 UITextField 的占位符文本颜色?我似乎无法访问占位符属性。谢谢
最佳答案
您可以使用属性字符串 设置占位符文本。将颜色设置为属性
属性(property)。
textField.attributedPlaceholder = NSAttributedString(string:"placeholder text",
attributes:[NSForegroundColorAttributeName: UIColor.yellowColor()])
swift 5
textField.attributedPlaceholder = NSAttributedString(string:"placeholder text", attributes:[NSAttributedString.Key.foregroundColor: UIColor.yellow])
关于ios - 快速更改占位符文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27683383/