iOS键盘类型
2021-11-18 本文已影响0人
BiBiMan
typedef NS_ENUM(NSInteger, UIKeyboardType) {
UIKeyboardTypeDefault, // Default type for the current input method.
UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters
UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad, // A number pad with locale-appropriate digits (0-9, ۰-۹, ०-९, etc.). Suitable for PIN entry.
UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
UIKeyboardTypeDecimalPad API_AVAILABLE(ios(4.1)), // A number pad with a decimal point.
UIKeyboardTypeTwitter API_AVAILABLE(ios(5.0)), // A type optimized for twitter text entry (easy access to @ #)
UIKeyboardTypeWebSearch API_AVAILABLE(ios(7.0)), // A default keyboard type with URL-oriented addition (shows space . prominently).
UIKeyboardTypeASCIICapableNumberPad API_AVAILABLE(ios(10.0)), // A number pad (0-9) that will always be ASCII digits.
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
};
IB属性
UIKeyboardTypeDefault
- 默认样式
- 可以输入数字、字母、符号、emoji
- 可输入中文,以及中/英切换 UIKeyboardTypeDefault
UIKeyboardTypeASCIICapable
- 只能输入数字、字母和符号,不能输入emoji和中文
- 适合输入密码等场景 UIKeyboardTypeASCIICapable
UIKeyboardTypeNumbersAndPunctuation
- 只能输入数字、字母、符号和中文,不能输入emoji UIKeyboardTypeNumbersAndPunctuation
UIKeyboardTypeURL
- 可以输入数字、字母、符号、emoji和中文
- 提供URL常用的
.com
、.
、/
热键 UIKeyboardTypeURL
UIKeyboardTypeNumberPad
- 只能输入0~9的纯数字 UIKeyboardTypeNumberPad
UIKeyboardTypePhonePad
- 只能输入0~9的纯数字,和
+ * #
符号 - 适合输入电话号码场景 UIKeyboardTypePhonePad
UIKeyboardTypeNamePhonePad
- 可以输入字母、数字、emoji和中文,不能输入特殊符号
- 能方便输入中/英文及数字
- 适用于联系人场景 UIKeyboardTypeNamePhonePad
UIKeyboardTypeEmailAddress
- 可以输入字母、数字、符号、emoji和中文
- 提供Email常用的
@
、.
热键 - 适合输入邮箱场景 UIKeyboardTypeEmailAddress
UIKeyboardTypeDecimalPad
- 可以输入0~9纯数字及小数点
.
- 适合含小数场景 UIKeyboardTypeDecimalPad
UIKeyboardTypeTwitter
- 可以输入字母、数字、符号、emoji和中文
- 提供
@
、#
热键 UIKeyboardTypeTwitter
UIKeyboardTypeWebSearch
- 可以输入字母、数字、符号、emoji和中文
- 提供
.
、go
热键 - 适合搜索场景 UIKeyboardTypeWebSearch
UIKeyboardTypeASCIICapableNumberPad
- 只能输入0~9纯数字,iOS 10及以后才能使用
- 适合纯数字场景 UIKeyboardTypeASCIICapableNumberPad