更改 TextField 中的清除按钮
change clear button in TextField
我需要知道是否可以更改文本字段中的清除按钮(放置图像)(我使用的文本字段来自 Material -> https://github.com/CosmicMind/Material)
现在我有一个 X :
但我想这样:
我找到了一些可能的代码:
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
我需要知道是否可以更改文本字段中的清除按钮(放置图像)(我使用的文本字段来自 Material -> https://github.com/CosmicMind/Material)
现在我有一个 X :
但我想这样:
我找到了一些可能的代码:
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