OneTimeCodeView
用swift编写的简单iOS库,提供了一个具有出色UX的UITextField
用于.oneTimeCode
安装
pod 'OneTimeCodeView', '~> 1.0.1'
填充代码视图
空视图
使用方法
@IBOutlet weak var oneTimeCodeView: OneTimeCodeView!
override func viewDidAppear(_ animated: Bool) {
// required:
self.oneTimeCodeView.configure(countOfDigits: NUMBER_COUNT)
self.oneTimeCodeView.didEnterLastDigit = { [weak self] (code) -> () in
print(code)
// TODO verify the code
}
}
// (optional) if you want to clear OneTimeCodeView if verification fails
func onVerificationError(error: Error) {
self.oneTimeCodeView.clear()
// display an error message
}