Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField textColor updates in iOS10, not in iOS 11

My code fragment is very small:

self.textField.textColor = color

This is called in response to user interaction. It has been working for years. On my iOS 10 device it still works. On my iOS 11 device, the color does not change until I tap in the text field.

Bug? Feature? Workaround? Suggestions welcome.

like image 367
Andrew Duncan Avatar asked Oct 15 '17 00:10

Andrew Duncan


Video Answer


2 Answers

You might need to update/reset your UITextField text right after the color change:

self.textField.textColor = color
self.textField.text = "Hi! I've changed of color!!"

Andrew update, more practical stuff:

 self.textField.textColor = color
 self.textField.text =  self.textField.text
like image 187
Karlo A. López Avatar answered Sep 28 '22 00:09

Karlo A. López


I can trigger the text color change to take effect by adding this line below the single line cited above:

self.textField.text = self.textField.text

However, given the facts above, it still looks to me like a bug outside of my code. Or, at least, a change of the implicit class contract.

like image 43
Andrew Duncan Avatar answered Sep 28 '22 00:09

Andrew Duncan