Skip to content

Commit c63ef29

Browse files
committed
Add keyboardType public property to modify keyboard of verification code view
1 parent a4844a3 commit c63ef29

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

KWVerificationCodeView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'KWVerificationCodeView'
3-
s.version = '0.1.6'
3+
s.version = '0.1.7'
44
s.summary = 'A verification code view with validation.'
55
s.description = 'A customisable verification code view with built in validation. Can be used for one time passwords (OTPs), email verification codes etc.'
66
s.homepage = 'https://github.com/keepworks/kwverificationcodeview'

KWVerificationCodeView/Classes/KWTextFieldView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ protocol KWTextFieldDelegate: class {
102102
private func setup() {
103103
loadViewFromNib()
104104
numberTextField.delegate = self
105+
numberTextField.autocorrectionType = UITextAutocorrectionType.no
106+
105107
NotificationCenter.default.addObserver(self, selector: #selector(textFieldDidChange(_:)), name: NSNotification.Name.UITextFieldTextDidChange, object: numberTextField)
106108
}
107109

KWVerificationCodeView/Classes/KWVerificationCodeView.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ public protocol KWVerificationCodeViewDelegate: class {
9898
}
9999
}
100100

101+
public var keyboardType: UIKeyboardType = UIKeyboardType.numberPad {
102+
didSet {
103+
for textFieldView in textFieldViews {
104+
textFieldView.numberTextField.keyboardType = keyboardType
105+
}
106+
}
107+
}
108+
101109
// MARK: - IBOutlets
102110
@IBOutlet var view: UIView!
103111

@@ -151,7 +159,7 @@ public protocol KWVerificationCodeViewDelegate: class {
151159

152160
public func hasValidCode() -> Bool {
153161
for textFieldView in textFieldViews {
154-
if Int(textFieldView.numberTextField.text!) == nil {
162+
if textFieldView.numberTextField.text?.trim() == nil {
155163
return false
156164
}
157165
}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ The properties which can be directly set in the *Attributes Inspector* and their
5151

5252
- `Dark Keyboard` - Default Keyboard Appearance
5353

54+
Customizable properties
55+
56+
- `keyboardType` - Sets the keyboard type (Defaults to Number Pad when not set)
57+
58+
verificationCodeView.keyboardType = UIKeyboardType.emailAddress
59+
60+
5461
### Variables
5562

5663
The `KWVerificationCodeView` has the following variables:

0 commit comments

Comments
 (0)