gpt4 book ai didi

ios - 自定义 UITextField 的 SelectedTextColor

转载 作者:行者123 更新时间:2023-11-29 12:26:50 24 4
gpt4 key购买 nike

如何自定义UITextField的selectedTextColor?默认为蓝色。

enter image description here

UITextField 委托(delegate)/通知仅在有文本更改时处理:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
- UITextFieldTextDidChangeNotification

最佳答案

假设您的目标是 iOS7+,您只需设置文本字段的 tintColor:

textField.tintColor = [UIColor purpleColor];

您还可以使用外观代理在您的应用中全局设置此设置(因此您无需为每个字段都这样做):

[[UITextField appearance] setTintColor:[UIColor purpleColor]];

它也可以在 Interface Builder 中单独完成,在属性检查器上,在 View -> Tint Color 下。

关于ios - 自定义 UITextField 的 SelectedTextColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28824961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com