Have any Question?

You can ask below or enter what you are looking for!

How to change UITextField placeholder color in Swift 3 and Interface Builder

You can change UITextField placeholder color programmatically or using interface builder

Changing UITextField placeholder color in Swift 3

1- Create a new UITextField subclass and  override its

layoutSubviews() and insert in it this line of code

self.setValue(UIColor.init(red: 178/255.0, green: 34/255.0, blue: 78/255.0, alpha: 0.5), forKeyPath: "_placeholderLabel.textColor")

2- Now select your view controller from storyboard and drag a new UITextField to it and from “Identity inspector” change its Class to your custom UITextField class and run.

Changing UITextField placeholder color in Interface Builder

Drag a new UITextFiled to your view controller then go to its “Identity inspector” and under “User Defined Runtime Attributes” add a new attribute with the following values:

Key Path: _placeholderLabel.textColor

Type: Color

Value: <my_color>

Finally press run

uitextfield placeholder color

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *