简体   繁体   English

iOS10中的UITextField textColor更新,而不是iOS 11中的更新

[英]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. 在我的iOS 10设备上它仍然有效。 On my iOS 11 device, the color does not change until I tap in the text field. 在我的iOS 11设备上,在我点击文本字段之前,颜色不会改变。

Bug? 错误? Feature? 特征? Workaround? 解决方法? Suggestions welcome. 建议欢迎。

You might need to update/reset your UITextField text right after the color change: 您可能需要在颜色更改后立即更新/重置UITextField文本:

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. 或者,至少是隐式类合同的变更。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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