iOS-键盘弹出的类型

iOS 提供了10种键盘类型,在开发中,我们可以根据不同的需求,选择不同的键盘样式,例如,当我们只需要输入手机号码时,可以选择纯数字类型的键盘(NumbersAndPunctuation),当我们需要输入网址时,可以选择URL样式的键盘(UIKeyboardTypeURL),其中,默认的键盘样式(UIKeyboardTypeDefault)就是(UIKeyboardTypeNamePhonePad)样式。


我们可以通过输入框的 keyboardType 来设置键盘样式

UITextField.keyboardType = UIKeyboardTypeNamePhonePad;
 1、  UIKeyboardTypeDefault,
        // Default type for the current input method.
 2、  UIKeyboardTypeASCIICapable,           
        // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
 3、  UIKeyboardTypeNumbersAndPunctuation,  
        // Numbers and assorted punctuation.
 4、  UIKeyboardTypeURL,                    
        // A type optimized for URL entry (shows . / .com prominently).
 5、  UIKeyboardTypeNumberPad,              
        // A number pad (0-9). Suitable for PIN entry.
 6、  UIKeyboardTypePhonePad,               
        // A phone pad (1-9, *, 0, #, with letters under the numbers).
 7、  UIKeyboardTypeNamePhonePad,           
        // A type optimized for entering a person's name or phone number.
 8、  UIKeyboardTypeEmailAddress,           
        // A type optimized for multiple email address entry (shows space @ . prominently).
 9、  UIKeyboardTypeDecimalPad NS_ENUM_AVAILABLE_IOS(4_1),   
        // A number pad with a decimal point.
 10、 UIKeyboardTypeTwitter    NS_ENUM_AVAILABLE_IOS(5_0),   
        // A type optimized for twitter text entry (easy access to @ #)
 11、 UIKeyboardTypeWebSearch NS_ENUM_AVAILABLE_IOS(7_0),    
        // A default keyboard type with URL-oriented addition (shows space . prominently).

下面一图像展示区别

UIKeyboardTypeDefault

这里写图片描述


UIKeyboardTypeNumbersAndPunctuation

这里写图片描述


UIKeyboardTypeURL

这里写图片描述


UIKeyboardTypeNumberPad

这里写图片描述


UIKeyboardTypePhonePad

这里写图片描述


UIKeyboardTypeEmailAddress

这里写图片描述


UIKeyboardTypeDecimalPad

这里写图片描述


UIKeyboardTypeTwitter

这里写图片描述


UIKeyboardTypeWebSearch

这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值