iOS 11 公测版 9 : UITextField textcolor can't be changed when no keyboard

标签 ios uitextfield ios11 xcode8

我正在开发一个需要更改 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/

相关文章:

html - 如果输入聚焦,iOS7 Safari 布局会因方向变化而中断

ios - 多采样渲染到纹理

swift - ARKit – 球没有穿过 "SCNTorus"孔

ios - Native Code Capture Image 在 IOS 11 上抛出异常?

ios - 如何更改 UISearchController 中文本字段的背景颜色?

ios - 将 ObjC NSNumber 代码迁移到 Swift 并在显示数字时遇到问题。

ios - 从 Firebase Swift 加载后单元格不显示图像

ios - 在开始编辑时选择 UISearchBar 中的所有文本?

ios - 如何在带有圆角的 UITextField 上添加阴影?

ios - 使文本字段背景透明,但占位符文本不透明