Reputation: 2666
I created a UITextField in code, now I have now idea how to define the keybaord that should appear ? I just get the standard keybboard, but I need a numberpad ?!
Thanks
Upvotes: 13
Views: 8842
Reputation: 16
You can specify the Keyboardtype like this:
.keyboardType(UIKeyboardType.numberPad)
here with some context:
@State var text : String = ""
TextField("text", text: self.$text).keyboardType(UIKeyboardType.numberPad)
Upvotes: 0
Reputation: 12389
Obj-C:
textField.keyboardType = UIKeyboardTypeNumberPad;
And simply use .numberPad
in Swift.
Upvotes: 12
Reputation: 15146
You need to set the keyboardType
property to UIKeyboardTypeNumberPad
.
Upvotes: 21