KWVerificationCodeView 0.5.0

KWVerificationCodeView 0.5.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布Jul 2023
SPM支持 SPM

KeepWorks 维护。



  • 作者:
  • KeepWorks

KWVerificationCodeView

Build Status Version License Platform

一个具有内置验证的可定制验证码视图。可用于一次性密码(OTPs),邮件验证码等。

Screenshot

示例

要运行示例项目,首先克隆回购,然后先从 Example 目录运行 pod install

需求

  • iOS 12 或更高版本
  • Swift 5.0
  • 最新版 Xcode

安装

KWVerificationCodeView 通过 CocoaPods 提供。安装它,只需在您的 Podfile 中添加以下行

pod "KWVerificationCodeView"

或者为了支持 Swift 4.2

pod "KWVerificationCodeView", '0.3.0'

或者为了支持 Swift 4

pod "KWVerificationCodeView", '0.2.0'

使用方法

在您的 Storyboard 中添加一个 UIView,并将其类更改为 KWVerificationCodeView。您可以在 属性检查器 中设置属性并查看实时预览

Interface Builder Screenshot

以下是可以直接在 属性检查器 中设置且具有默认值的属性

  • 下划线颜色 - 深灰色颜色

  • 选中下划线颜色 - 黑色颜色

  • 文本颜色 - 深文本颜色

  • 数字 - 4

  • 文本大小 - 24.0

  • 文本字体 - 系统字体

  • 文本字段背景颜色 - 透明颜色

  • 文本字段着色颜色 - 蓝色颜色

  • 暗键盘 - 默认键盘外观

可定制的属性

  • keyboardType - 设置键盘类型(默认为数字键盘,当未设置时)

    verificationCodeView.keyboardType = UIKeyboardType.emailAddress
    

变量

KWVerificationCodeView 拥有以下变量

isTappable: Bool

使 KWVerficationCodeView 可点击。默认值为 false

方法

KWVerificationCodeView具有以下方法

hasValidCode() -> Bool

当输入的密码有效时,返回true。

getVerificationCode() -> String

聚焦到第一个文本字段

focus()

返回验证码

clear()

清除验证码视图和第一个字段变为响应者

协议

KWVerificationCodeViewDelegate

KWVerificationCodeViewDelegate 协议有以下方法

didChangeVerificationCode()

通知 KWVerificationCodeView中的文本已更改。这在您需要仅当验证码有效时启用提交按钮的情况下特别有用。

作者

KeepWorks, [email protected]

致谢

KWVerificationCodeView 由 KeepWorks 拥有和维护。

N|Solid

贡献

欢迎在 GitHub 上提交问题和拉取请求:https://github.com/keepworks/KWVerificationCodeView

许可协议

KWVerificationCodeView 采用 MIT 许可协议。更多信息请参阅 许可协议文件