Swift offers 11 types of keyboards:
In the development, we can choose different keyboard styles according to different needs, for example, when we only need to enter the phone number, we can choose the pure numeric type of keyboard (. Numbersandpunctuation), when we need to enter a URL, you can choose a URL-style keyboard (. url), where the default keyboard style (. Default) is the (. namephonepad) style.
We can set the keyboard style by uikeyboardtype the input box
Uitextfield(). Keyboardtype =. Namephonepad
//
Uikeyboardtype
//
Requests that a particular keyboard type is displayed when a text widget
becomes first responder.
Note:some Keyboard/input methods types may not support every variant.
In such cases, the input method would make a best effort to find a close
Match to the requested type (e.g. displaying uikeyboardtypenumbersandpunctuation
Type if Uikeyboardtypenumberpad is not supported).
//
Public enum uikeyboardtype: Int {
case Default //default type for the current input method.
case asciicapable //displays a keyboard which can enter ASCII characters, non-ascii keyboards remain active
case numbersandpunctuation //Numbers and assorted punctuation.
case URL //A type optimized for URL entry (shows./. com prominently).
case Numberpad //A number pad (0-9). Suitable for PIN entry.
case Phonepad //A phone pad (1-9, *, 0, #, with letters under the numbers).
case Namephonepad //a type optimized for entering a person ' s name or phone number.
case EmailAddress //A type optimized for multiple email address entry (shows space @. prominently).
@available(IOS 4.1, *)
case Decimalpad //A number pad with A decimal point.
@available(IOS 5.0, *)
Case Twitter //A type optimized-Twitter text entry (easy access to @ #)
@available(IOS 7.0, *)
case websearch //A default keyboard type with url-oriented addition (shows space. prominently).
public static var Alphabet: uikeyboardtype {get} //Deprecated
}
The following image shows the difference
Default
Numbersandpunctuation
Url
Numberpad
Phonepad
EmailAddress
Decimalpad
Twitter
Websearch
Swift-keyboard Popup style