DigitInputView 1.1.1

DigitInputView 1.1.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2018年7月
SPM支持SPM

Milad Nozari维护。



DigitInputView

CI Status Version License Platform

DigitInputView

安装

DigitInputView通过CocoaPods提供。要安装它,只需将以下行添加到Podfile中

pod "DigitInputView"

或者,您可以将DigitInputView/Classes/DigitInputView.swift直接复制到您的项目中。

使用

您可以按照以下代码片段调整视图的外观和感觉。

digitInput = DigitInputView()
    
digitInput.numberOfDigits = 6
digitInput.bottomBorderColor = .purple
digitInput.nextDigitBottomBorderColor = .red
digitInput.textColor = .purple
digitInput.acceptableCharacters = "0123456789"
digitInput.keyboardType = .decimalPad
digitInput.font = UIFont.monospacedDigitSystemFont(ofSize: 10, weight: 1)
digitInput.animationType = .spring
digitInput.keyboardAppearance = .dark

选项

numberOfDigits

显示的数字(字符)数量

类型:整型

默认:4

bottomBorderColor

数字下线条的颜色

类型:UIColor

默认:UIColor.lightGray

nextDigitBottomBorderColor

用户即将输入的数字下线条的颜色

类型:UIColor

默认:UIColor.gray

textColor

文字的颜色

类型:UIColor

默认:UIColor.black

acceptableCharacters

如果设置,则只有此字符串中的字符被接受。其他内容将被忽略。

类型:String?

默认:nil

keyboardType

显示给用户的键盘类型。

类型:UIKeyboardType

默认:UIKeyboardType.default

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.

    
    public static var alphabet: UIKeyboardType { get } // Deprecated
}

animationType

显示新数字时使用的动画类型(由用户输入时使用)

类型:DigitInputViewAnimationType

默认:.spring


public enum DigitInputViewAnimationType: Int {
    case none, dissolve, spring
}

font

用于标签的字体。

类型:UIFont?

默认:nil(默认系统字体)

keyboardAppearance

选择键盘外观的选项。可能的值有

default:该值映射到light

dark:选择深色键盘

light:选择浅色键盘

alert:适合提示框的外观

示例

要运行示例项目,请先克隆存储库,然后从示例目录运行 pod install

作者

mnvoh,[email protected]

许可

DigitInputView采用MIT许可。有关更多信息,请参阅LICENSE文件。