1、键盘风格

  1. typedef NS_ENUM(NSInteger, UIKeyboardType) {
  2. UIKeyboardTypeDefault, // Default type for the current input method.
  3. UIKeyboardTypeASCIICapable, // Displays a keyboard which can enter ASCII characters
  4. UIKeyboardTypeNumbersAndPunctuation, // Numbers and assorted punctuation.
  5. UIKeyboardTypeURL, // A type optimized for URL entry (shows . / .com prominently).
  6. UIKeyboardTypeNumberPad, // A number pad with locale-appropriate digits (0-9, ۰-۹, ०-९, etc.). Suitable for PIN entry.
  7. UIKeyboardTypePhonePad, // A phone pad (1-9, *, 0, #, with letters under the numbers).
  8. UIKeyboardTypeNamePhonePad, // A type optimized for entering a person's name or phone number.
  9. UIKeyboardTypeEmailAddress, // A type optimized for multiple email address entry (shows space @ . prominently).
  10. UIKeyboardTypeDecimalPad API_AVAILABLE(ios(4.1)), // A number pad with a decimal point.
  11. UIKeyboardTypeTwitter API_AVAILABLE(ios(5.0)), // A type optimized for twitter text entry (easy access to @ #)
  12. UIKeyboardTypeWebSearch API_AVAILABLE(ios(7.0)), // A default keyboard type with URL-oriented addition (shows space . prominently).
  13. UIKeyboardTypeASCIICapableNumberPad API_AVAILABLE(ios(10.0)), // A number pad (0-9) that will always be ASCII digits.
  14. UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
  15. };
  • UIKeyboardTypeDefault: 默认键盘,支持所有

image.png

  • UIKeyboardTypeASCIICapable: 支持ASCII的默认键盘

image.png

  • UIKeyboardTypeNumbersAndPunctuation: 数字键盘

image.png

  • UIKeyboardTypeURL: URL键盘,支持URL,有.com按钮

image.png

  • UIKeyboardTypeNumberPad: 数字键盘

image.png

  • UIKeyboardTypePhonePad: 电话键盘

image.png

  • UIKeyboardTypeNamePhonePad: 支持输入用户名字的电话键盘

image.png
image.png

  • UIKeyboardTypeEmailAddress: 邮箱键盘,主要用于输入邮箱地址

image.png

  • UIKeyboardTypeDecimalPad: 带小数点的键盘

image.png

  • UIKeyboardTypeTwitter: 具有@,#按钮

image.png

  • UIKeyboardTypeWebSearch:

image.png

  • UIKeyboardTypeASCIICapableNumberPad: 已经过期

image.png

  • UIKeyboardTypeAlphabet: 已经过期

image.png

使用:

  1. password.keyboardtype = UIKeyboardTypeNumberPad;

2、键盘外观

  1. typedef NS_ENUM(NSInteger, UIKeyboardAppearance) {
  2. UIKeyboardAppearanceDefault, // Default appearance for the current input method.
  3. UIKeyboardAppearanceDark API_AVAILABLE(ios(7.0)),
  4. UIKeyboardAppearanceLight API_AVAILABLE(ios(7.0)),
  5. UIKeyboardAppearanceAlert = UIKeyboardAppearanceDark, // Deprecated
  6. };
  • UIKeyboardAppearanceDefault

image.png

  • UIKeyboardAppearanceDark

image.png

  • UIKeyboardAppearanceLight

image.png

  • UIKeyboardAppearanceAlert

image.png

3、回车键

  1. typedef NS_ENUM(NSInteger, UIReturnKeyType) {
  2. UIReturnKeyDefault,
  3. UIReturnKeyGo,
  4. UIReturnKeyGoogle,
  5. UIReturnKeyJoin,
  6. UIReturnKeyNext,
  7. UIReturnKeyRoute,
  8. UIReturnKeySearch,
  9. UIReturnKeySend,
  10. UIReturnKeyYahoo,
  11. UIReturnKeyDone,
  12. UIReturnKeyEmergencyCall,
  13. UIReturnKeyContinue API_AVAILABLE(ios(9.0)),
  14. };
UIReturnKeyDefault image.png
UIReturnKeyGo image.png
UIReturnKeyGoogle image.png
UIReturnKeyJoin image.png
UIReturnKeyNext image.png
UIReturnKeyRoute image.png
UIReturnKeySearch image.png
UIReturnKeySend image.png
UIReturnKeyYahoo image.png
UIReturnKeyDone image.png
UIReturnKeyEmergencyCall image.png
UIReturnKeyContinue: 过期 image.png

**self**.textView.returnKeyType = UIReturnKeyContinue;

4、自动大写

typedef NS_ENUM(NSInteger, UITextAutocapitalizationType) {
    UITextAutocapitalizationTypeNone,
    UITextAutocapitalizationTypeWords,
    UITextAutocapitalizationTypeSentences,
    UITextAutocapitalizationTypeAllCharacters,
};

// use
self.textView.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
  • UITextAutocapitalizationTypeNone
  • UITextAutocapitalizationTypeWords: 单词首字母大写
  • UITextAutocapitalizationTypeSentences: 句子首字母大写
  • UITextAutocapitalizationTypeAllCharacters: 所有字母大写

5、自动更正

typedef NS_ENUM(NSInteger, UITextAutocorrectionType) {
    UITextAutocorrectionTypeDefault,
    UITextAutocorrectionTypeNo,
    UITextAutocorrectionTypeYes,
};

// 使用
password.autocorrectionType = UITextAutocorrectionTypeYes;

6、安全文本输入

extView.secureTextEntry=YES;