How to change UITextfield
placeholder
& fontsize
in SWIFT 2.0?
It's easy to do with a subclass of UITextField.
Add placeholderColor
property to easily set the color, and then observer changing of .placeholder
to apply the color to it (with use of .attributedPlaceholder
property)
var placeholderColor: UIColor = .lightGray
override var placeholder: String? {
didSet {
let attributes = [ NSAttributedString.Key.foregroundColor: placeholderColor ]
attributedPlaceholder = NSAttributedString(string: placeholder ?? "", attributes: attributes)
}
}
You do need to set the placeholder text programatically for the color to apply.