简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM