Swift - 键盘弹出样式

Swift提供了11种键盘类型:web

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


咱们能够经过输入框的 UIKeyboardType 来设置键盘样式ui

 UITextField().keyboardType = .NamePhonePadurl

//

// UIKeyboardTypespa

//code

// Requests that a particular keyboard type be displayed when a text widget图片

// becomes first responder. ip

// Note: Some keyboard/input methods types may not support every variant. ci

// 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

这里写图片描述

相关文章
相关标签/搜索