Programmatically change UITextField Keyboard type

前端 未结 12 1292
不知归路
不知归路 2020-11-28 19:28

Is it possible to programmatically change the keyboard type of a uitextfield so that something like this would be possible:

if(user is prompted for numeric i         


        
12条回答
  •  时光取名叫无心
    2020-11-28 19:57

    Programmatically change UITextField Keyboard type swift 3.0

    lazy var textFieldTF: UITextField = {
    
        let textField = UITextField()
        textField.placeholder = "Name"
        textField.frame = CGRect(x:38, y: 100, width: 244, height: 30)
        textField.textAlignment = .center
        textField.borderStyle = UITextBorderStyle.roundedRect
        textField.keyboardType = UIKeyboardType.default //keyboard type
        textField.delegate = self
        return textField 
    }() 
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(textFieldTF)
    }
    

提交回复
热议问题