📌  相关文章
📜  xcode 在填充文本字段后启用按钮 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:01:00.404000             🧑  作者: Mango

代码示例1
@objc func editingChanged(_ textField: UITextField) {
    if textField.text?.characters.count == 1 {
        if textField.text?.characters.first == " " {
            textField.text = ""
            return
        }
    }
    guard
        let habit = habitNameField.text, !habit.isEmpty,
        let goal = goalField.text, !goal.isEmpty,
        let frequency = frequencyField.text, !frequency.isEmpty
    else {
        doneBarButton.isEnabled = false
        return
    }
    doneBarButton.isEnabled = true
}