【发布时间】:2021-11-17 18:11:02
【问题描述】:
【问题讨论】:
【问题讨论】:
根据您的问题,您只需将按钮添加到文本字段 inputAccessoryView。
yourTextField.inputAccessoryView = confirmButton
要处理原始按钮位置,请临时创建一个与原始按钮相同的按钮,包括方法名称。
let tempButton = UIButton(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 30))
tempButton.backgroundColor = UIColor.blue
tempButton.setTitle("YourConfirmButton", for: .normal)
tempButton.setTitleColor(UIColor.white, for: .normal)
tempButton.addTarget(self, action: #selector(self.onTapConfirmButton), for: .touchUpInside)
yourTextField.inputAccessoryView = tempButton
【讨论】: