Numeric keyboard with decimal

Kevin picture Kevin · Feb 16, 2016 · Viewed 34.6k times · Source

I´m building an app with equations and I have used a numeric keyboard but I want to have a decimal slot on it. The default is only numbers. How do you add a decimal input on that keyboard?

This is the code I use to get the numeric keyboard

.keyboardType = UIKeyboardType.NumberPad

Answer

tktsubota picture tktsubota · Feb 16, 2016

Simply change the keyboard type:

self.someTextField.keyboardType = UIKeyboardType.decimalPad

See the documentation for all the keyboard types.