1.键盘风格
代码 | xib(Keyboard Type) | 释义 |
---|---|---|
UIKeyboardTypeDefault | Default | 默认键盘,支持所有字符 |
UIKeyboardTypeASCIICapable | ASCII Capable | 支持ASCII的键盘 |
UIKeyboardTypeNumbersAndPunctuation | Numbers and Punctuation | 数字和标点符号键盘 |
UIKeyboardTypeURL | URL | 用于输入URL的键盘 |
UIKeyboardTypeNumberPad | Number Pad | 数字键盘(只有数字) |
UIKeyboardTypePhonePad | Phone Pad | 电话键盘(数字、+*#) |
UIKeyboardTypeNamePhonePad | Name Phone Pad | 支持输入人名的电话键盘 |
UIKeyboardTypeEmailAddress | E-mail Address | 用于输入邮件地址的键盘 |
UIKeyboardTypeDecimalPad | Decimal Pad | 小数键盘(比数字键盘多一个小数点) |
UIKeyboardTypeTwitter | 一种优化的推特文本输入键盘 | |
UIKeyboardTypeWebSearch | Web Search | 略(iOS7.0以后才支持) |
UIKeyboardTypeAlphabet | 等于UIKeyboardTypeASCIICapable | 已经过时 |
UIKit框架支持以下几种键盘风格:
代码 | xib(Keyboard Type) | 释义 |
---|---|---|
UIKeyboardTypeDefault | Default | 默认键盘,支持所有字符 |
UIKeyboardTypeASCIICapable | ASCII Capable | 支持ASCII的键盘 |
UIKeyboardTypeNumbersAndPunctuation | Numbers and Punctuation | 数字和标点符号键盘 |
UIKeyboardTypeURL | URL | 用于输入URL的键盘 |
UIKeyboardTypeNumberPad | Number Pad | 数字键盘(只有数字) |
UIKeyboardTypePhonePad | Phone Pad | 电话键盘(数字、+*#) |
UIKeyboardTypeNamePhonePad | Name Phone Pad | 支持输入人名的电话键盘 |
UIKeyboardTypeEmailAddress | E-mail Address | 用于输入邮件地址的键盘 |
UIKeyboardTypeDecimalPad | Decimal Pad | 小数键盘(比数字键盘多一个小数点) |
UIKeyboardTypeTwitter | 一种优化的推特文本输入键盘 | |
UIKeyboardTypeWebSearch | Web Search | 略(iOS7.0以后才支持) |
UIKeyboardTypeAlphabet | 等于UIKeyboardTypeASCIICapable | 已经过时 |
代码中的用法:
textField.keyboardType = UIKeyboardTypeNumberPad;
2.键盘外观
代码 | xib(Appearance) | 释义 |
---|---|---|
UIKeyboardAppearanceDefault | Default | 默认外观:浅灰色 |
UIKeyboardAppearanceAlert | Dark | 深灰:石墨色 |
UIKeyboardAppearanceDark | Dark | 深灰:石墨色(iOS7.0以后,用于替代UI…Alert) |
UIKeyboardAppearanceLight | Light | 亮灰:趋近于白色 |
代码中的用法:
textField.keyboardAppearance = UIKeyboardAppearanceAlert;
3.自动大写
代码 | xib(Capitalization) | 释义 |
---|---|---|
UITextAutocapitalizationTypeNone | None | 不自动大写 |
UITextAutocapitalizationTypeWords | Words | 单词首字母大写 |
UITextAutocapitalizationTypeSentences | Sentences | 句子首字母大写 |
UITextAutocapitalizationTypeAllCharacters | All Characters | 所有字母大写 |
代码中的用法:
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
4.自动更正
代码 | xib | 释义 |
---|---|---|
UITextAutocorrectionTypeDefault | Default | 默认 |
UITextAutocorrectionTypeNo | No | 不自动更正 |
UITextAutocorrectionTypeYes | Yes | 自动更正 |
代码中的用法:
textField.autocorrectionType = UITextAutocorrectionTypeYes;