MKOtpView 1.0.0

MKOtpView 1.0.0

Mohit Kumar 维护。



MKOtpView 1.0.0

  • mohit5189

MKOtpView

CI Status

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

要求

iOS 8.0 或更高版本。

安装

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

pod 'MKOtpView'

实现步骤

  1. 通过传递框架创建 MKOtpView 对象
var otpView:MKOtpView!
otpView = MKOtpView(frame: CGRect(x: 10, y: 100, width: 350, height: 50))
  1. 现在您可以设置以下不同属性
otpView = MKOtpView(frame: CGRect(x: 10, y: 100, width: 350, height: 50))
otpView.setVerticalPedding(pedding: 5)
otpView.setHorizontalPedding(pedding: 5)
otpView.setNumberOfDigits(numberOfDigits: 6)
otpView.setBorderWidth(borderWidth: 2.0)
otpView.setBorderColor(borderColor: UIColor.green)
otpView.setCornerRadius(radius: 2)
otpView.setInputBackgroundColor(inputBackgroundColor: UIColor.white)
otpView.backgroundColor = UIColor.lightGray
otpView.enableSecureEntries()
self.view.addSubview(otpView)
  1. 设置闭包以填写所有 OTP 字段后获得响应,您可以在此处编写自己的逻辑来使用填充的数字。
otpView.onFillDigits = { number in
print("input number is \(number)")
}

  1. 最终,设置一切完成后,调用一次渲染方法。
otpView.render()

作者

穆希特·库马尔

许可证

MKOtpView 可在 MIT 许可下使用。更多信息请参阅 LICENSE 文件。