Custom UITextField clear button

前端 未结 7 948
渐次进展
渐次进展 2021-01-31 08:16

Is it possible to customize the image of the clear button in a UITextField? I have a dark textfield background and the \"x\" is not visible enough.

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-31 08:52

    Swift 2.2+ / iOS 9+ version of @Brody Robertson's answer:

    let defaultClearButton = UIButton.appearanceWhenContainedInInstancesOfClasses([UITextField.self])
    defaultClearButton.setBackgroundImage(UIImage(named: "ClearIcon"), forState: UIControlState.Normal)
    

提交回复
热议问题