Swift - 鍵盤彈出樣式

來源:互聯網
上載者:User

標籤:技術   character   pac   request   sts   arc   dig   boa   ati   

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

  

Swift - 鍵盤彈出樣式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.