Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>OTPFieldView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
25 changes: 25 additions & 0 deletions OTPFieldView/OTPFieldView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,28 @@ extension OTPFieldView: UITextFieldDelegate {
calculateEnteredOTPSTring(isDeleted: true)
}
}
extension OTPFieldView {
public func clearAllTextFields() {
// Iterate through all OTP text fields and clear their text
for index in stride(from: 0, to: fieldsCount, by: 1) {
if let otpField = viewWithTag(index + 1) as? OTPTextField {
otpField.text = ""
secureEntryData[index] = ""

// Reset background and border colors to default
if displayType == .diamond || displayType == .underlinedBottom {
if let shapeLayer = otpField.shapeLayer {
shapeLayer.fillColor = defaultBackgroundColor.cgColor
shapeLayer.strokeColor = defaultBorderColor.cgColor
}
} else {
otpField.backgroundColor = defaultBackgroundColor
otpField.layer.borderColor = defaultBorderColor.cgColor
}
} else {
// Handle case when otpField is not found (optional)
print("Warning: OTP field with tag \(index + 1) not found.")
}
}
}
}