gpt4 book ai didi

objective-c - 自定义 UITextField 清除按钮

转载 作者:IT王子 更新时间:2023-10-29 07:44:55 24 4
gpt4 key购买 nike

是否可以在 UITextField 中自定义清除按钮的图像?我有一个深色的文本字段背景,“x”不够明显。

最佳答案

您可以将自己的自定义清除按钮设置为文本字段的 rightView 属性。确保将 rightViewMode 属性设置为 UITextFieldViewModeWhileEditingUITextFieldViewModeAlways,无论您的情况如何。

如果按钮的位置不适合您的需要,您可以子类化 UITextField 并覆盖 rightViewRectForBounds: 方法。

文档说 clearButtonMode 属性的默认值是 UITextFieldViewModeNever,但我怀疑 Interface Builder 可能会将其设置为 UITextFieldViewModeWhileEditing - 确保你将其设置为“从不”值,这样它就不会出现。

所有这些属性都记录在 UITextField Class Reference 中.

关于objective-c - 自定义 UITextField 清除按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9239328/

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