我正在开发一个需要更改 UITextfield 的文本颜色的应用程序。 我为此编写了以下代码。
-(IBAction)changedSegment:(UISegmentedControl *)segment{
UIColor *color = arrColors[segment.selectedSegmentIndex];
txtDemo.textColor = color;
}
它在 iOS 10 中运行良好。但在 iOS 11 beta 9 中,当键盘被隐藏时(从响应器中退出),文本颜色无法更改。
最佳答案
只需添加
[txtDemo setNeedsLayout];
关于iOS 11 公测版 9 : UITextField textcolor can't be changed when no keyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46178078/