Scott Haley
Scott Haley

Reputation: 43

Change color of placeholder text on keyboard in iOS 10

In iOS 10, if you select an input with a placeholder, the placeholder text will show on the keyboard like so:

enter image description here

The text color however is very light and difficult to read.

Is there a way to change this color?

Upvotes: 0

Views: 1076

Answers (2)

Ennabah
Ennabah

Reputation: 2533

This will make it easy to control the place holder color inside of the storyboard

@IBInspectable var placeHolderColor: UIColor? {
    didSet {
        let rawString = attributedPlaceholder?.string != nil ? attributedPlaceholder!.string : ""
        let str = NSAttributedString(string: rawString, attributes: [NSForegroundColorAttributeName: placeHolderColor!])
        attributedPlaceholder = str
    }
}

Upvotes: 0

bearacuda13
bearacuda13

Reputation: 1854

There is!

Connect your text field to your viewController, then assign it a color programmatically.

myTextField.setPlaceholderColor(UIColor.black)

Upvotes: 3

Related Questions