• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Swift - 键盘弹出样式

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Swift提供了11种键盘类型:

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


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

 UITextField().keyboardType = .NamePhonePad

//

// UIKeyboardType

//

// Requests that a particular keyboard type be 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 will 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 for 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

}

下面一图像展示区别

Default


NumbersAndPunctuation


URL


NumberPad


PhonePad


EmailAddress


DecimalPad


Twitter


WebSearch


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap