iOS开发中键盘样式和自定义键盘。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Bolted_snail/article/details/84991425

系统自带的样式

  • 在iOS开发中系统自带键盘已经有很多样式,但是有时候并不能满足我们都开发需求,需要或大或小的改动,这时候就需要我们自定义键盘了,系统自带键盘样式如下:
public enum UIKeyboardType : Int {
    case `default` // Default type for the current input method.
    case asciiCapable // Displays a keyboard which can enter ASCII characters
    case numbersAndPunctuation // Numbers and assorted punctuation.
    case URL // A type optimized for URL entry (shows . / .com prominently).
    case numberPad // A number pad with locale-appropriate digits (0-9, ۰-۹, ०-९, etc.). 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).
    @available(iOS 10.0, *)
    case asciiCapableNumberPad // A number pad (0-9) that will always be ASCII digits.
}

默认键盘效果图如下:
系统自带键盘样式

自定义键盘

  • 有时候我们需要在原有的键盘上加一些控件,不需要改变原有键盘的布局,这时候只需要监听键盘的弹出和退出的通知,计算frame,然后再window天健对应的控件即可。有时候系统自带键盘都没法满足我们都需求就需要完全自定义键盘了。

在系统自带键盘基础上自定义键盘

完全自定义键盘



参考文档:
深入讲解iOS键盘三:自定义键盘的两种方法
iOS自定义安全键盘
iOS自定义键盘

猜你喜欢

转载自blog.csdn.net/Bolted_snail/article/details/84991425