How to limit iOS keyboard to numeric input

Jack BeNimble picture Jack BeNimble · Sep 14, 2011 · Viewed 27.7k times · Source

The question pretty much says it all. Is there any way to have the iOS/iPhone keyboard default to numeric input?

Answer

Ravi picture Ravi · Sep 14, 2011

Set the keyboardType property of the UITextField to UIKeyboardTypeDecimalPad.

Swift 3

yourUITextField.keyboardType = .decimalPad