Change the color of placeholder text to swift
5 answers
You can subclass the textbox and override the DrawRect function of the textbox. By subclassing, you can easily set this for each text field.
class CustomTextfield :UITextField {
override func drawRect(rect: CGRect) {
self.attributedPlaceholder = NSAttributedString(string:self.placeholder != nil ? self.placeholder! : "", attributes:[NSForegroundColorAttributeName: UIColor.grayColor()])
} }
+1
source to share