Skyscanner / SkyFloatingLabelTextField

A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.
Apache License 2.0
4.09k stars 540 forks source link

Attributed text support #328

Open mluisbrown opened 3 years ago

mluisbrown commented 3 years ago

Adds support for using setting the attributedText property of the UITextField.

Setting this value was always possible of course, but the logic of SkyFloatingLabelTextField in reaction to other changes (eg isEnabled, active, not active etc) always calls updateColors() which in turn calls updateTextColor() which in setting the textColor value of the UITextField overrides any color attributes that have been set in the attributedText, making it basically unusable.

With this change, if attributedText is set to a non-nil value, any changes to textColor are ignored, and internally the attributed string will remain unchanged when updateTextColor() is called, except to set it to the error color in the case of an error.