gpt4 book ai didi

swift - 更改 TextField 中的清除按钮

转载 作者:行者123 更新时间:2023-11-28 10:31:04 25 4
gpt4 key购买 nike

我需要知道是否可以更改文本字段中的清除按钮(放置图像)(我正在使用 Material -> https://github.com/CosmicMind/Material 中的文本字段)

现在我有一个 X : enter image description here

但我想这样: enter image description here

我找到了一些可能的代码:

let customClearButton = UIButton.appearance(whenContainedInInstancesOf: [UITextfield.self])
customClearButton.setBackgroundImage(UIImage(named: "icon_info"), for: .normal)

但是当我输入文本字段时它不起作用,错误是:

Cannot convert value of type 'TextField?' to expected element type 'UIAppearanceContainer.Type'

非常感谢您的帮助。

最佳答案

您是否尝试过 clearIconButton?.image = UIImage(named: "cameraIcon") 用于 Material TextField

关于swift - 更改 TextField 中的清除按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55922378/

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