UITextField是不可编辑的Swift

时间:2020-04-07 15:18:51

标签: swift xcode uitextfield

我已经实现了UITextFieldDelegate并将isUserInteractionEnabled设置为true,但是textField仍然不可编辑,有一些建议吗?

lazy var myTextField: UITextField = {
    let text = UITextField()
    text.translatesAutoresizingMaskIntoConstraints = false
    text.isUserInteractionEnabled = true

    text.backgroundColor = .white
    text.textColor = .black
    text.borderStyle = .line
    text.placeholder = "Enter your text"

    return text
}()

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
    return true
}

0 个答案:

没有答案