diff --git a/OTPFieldView/OTPFieldView.swift b/OTPFieldView/OTPFieldView.swift index bcee25d..b312077 100644 --- a/OTPFieldView/OTPFieldView.swift +++ b/OTPFieldView/OTPFieldView.swift @@ -243,6 +243,15 @@ import UIKit } } } + + public func setFullOTPCode(_ code: String) { + secureEntryData = code.map { String($0) } + for index in 0 ..< secureEntryData.count { + if let otpField = viewWithTag(index + 1) as? OTPTextField { + otpField.text = secureEntryData[index] + } + } + } } diff --git a/README.md b/README.md index bc57408..21e6ae5 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,15 @@ extension OtpViewController: OTPFieldViewDelegate { - **shouldBecomeFirstResponderForOTP()**: Show keyboard automatically. - **enteredOTP()**: Get entered pin. + +### Set full otp code + +```swift +self.otpTextFieldView.setFullOTPCode("22222") +``` + +- **setFullOTPCode()**: Use in case of setting OTP code in OTPTextViewField programmatically. + ### Properties - **.displayType**: Display type for Text Field.