【问题标题】:change clear button in TextField更改 TextField 中的清除按钮
【发布时间】:2019-09-19 04:48:56
【问题描述】:

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

现在我有一个 X :

但我想这样:

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

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

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

无法转换“TextField”类型的值?到预期的元素类型 'UIAppearanceContainer.Type'

非常感谢您的帮助。

【问题讨论】:

    标签: swift button textfield


    【解决方案1】:

    您是否尝试过clearIconButton?.image = UIImage(named: "cameraIcon") 的材料TextField

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 2023-03-19
      • 2012-07-05
      • 1970-01-01
      • 2020-08-15
      • 2018-04-12
      相关资源
      最近更新 更多