How can I set the normal color for a floating placeholder in a MDCMultilineTextField?

493 Views Asked by At

I'm having troubles changing the color of the placeholder of a MDCMultilineTextField in the non-active state. I'm using a MDCTextInputControllerUnderline and I've managed to personalize every other part of the textfield, with the exception of the floating placeholder when not active (see pictures below, I need it to be white).

enter image description here

enter image description here

I've tried setting the tintColor of the textfield, the textColor and the tintColor of the placeholderLabel, the normalColor, inlinePlaceholderColor, floatingPlaceholderNormalColor and floatingPlaceholderActiveColor of the controller, but nothing seems to work. What am I missing? What's the attribute to change to set the color of the placeholder?

1

There are 1 best solutions below

0
On BEST ANSWER

As suggested in the comment, it was a matter of setting the Attributed Placeholder instead of the regular one.

So, in the end, it was just a matter of doing this:

    let stringAttr = [NSAttributedStringKey.foregroundColor: UIColor.white]
    let attributedPlaceholder = NSAttributedString(string: placeholder, attributes: stringAttr)
    textField.attributedPlaceholder = attributedPlaceholder