Skip to content

Commit 87acf0a

Browse files
author
Athul Sai
committed
Updated readme file and fixed text spacing issues.
1 parent 9ca5244 commit 87acf0a

4 files changed

Lines changed: 53 additions & 16 deletions

File tree

KWVerificationCodeView/Classes/KWTextFieldView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@ protocol KWTextFieldDelegate: class {
2525
underlineView.backgroundColor = underlineColor
2626
}
2727
}
28+
2829
@IBInspectable var underlineSelectedColor: UIColor = UIColor.black
30+
2931
@IBInspectable var textColor: UIColor = UIColor.darkText {
3032
didSet {
3133
numberTextField.textColor = textColor
3234
}
3335
}
36+
3437
@IBInspectable var textSize: CGFloat = 24.0 {
3538
didSet {
3639
numberTextField.font = UIFont.systemFont(ofSize: textSize)
3740
}
3841
}
42+
3943
@IBInspectable var textFont: String = "" {
4044
didSet {
4145
if textFont.trim() == "" {
@@ -49,16 +53,19 @@ protocol KWTextFieldDelegate: class {
4953
}
5054
}
5155
}
56+
5257
@IBInspectable var textFieldBackgroundColor: UIColor = UIColor.clear {
5358
didSet {
5459
numberTextField.backgroundColor = textFieldBackgroundColor
5560
}
5661
}
62+
5763
@IBInspectable var textFieldTintColor: UIColor = UIColor.blue {
5864
didSet {
5965
numberTextField.tintColor = textFieldTintColor
6066
}
6167
}
68+
6269
@IBInspectable var darkKeyboard: Bool = false {
6370
didSet {
6471
if darkKeyboard {

KWVerificationCodeView/Classes/KWVerificationCodeView.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,31 @@ public protocol KWVerificationCodeViewDelegate: class {
2525
}
2626
}
2727
}
28+
2829
@IBInspectable var underlineSelectedColor: UIColor = UIColor.black {
2930
didSet {
3031
for textFieldView in textFieldViews {
3132
textFieldView.underlineSelectedColor = underlineSelectedColor
3233
}
3334
}
3435
}
36+
3537
@IBInspectable var textColor: UIColor = UIColor.darkText {
3638
didSet {
3739
for textFieldView in textFieldViews {
3840
textFieldView.numberTextField.textColor = textColor
3941
}
4042
}
4143
}
44+
4245
@IBInspectable var textSize: CGFloat = 24.0 {
4346
didSet {
4447
for textFieldView in textFieldViews {
4548
textFieldView.numberTextField.font = UIFont.systemFont(ofSize: textSize)
4649
}
4750
}
4851
}
52+
4953
@IBInspectable var textFont: String = "" {
5054
didSet {
5155
if textFont.trim() == "" {
@@ -62,42 +66,40 @@ public protocol KWVerificationCodeViewDelegate: class {
6266
}
6367
}
6468
}
69+
6570
@IBInspectable var textFieldBackgroundColor: UIColor = UIColor.clear {
6671
didSet {
6772
for textFieldView in textFieldViews {
6873
textFieldView.numberTextField.backgroundColor = textFieldBackgroundColor
6974
}
7075
}
7176
}
77+
7278
@IBInspectable var textFieldTintColor: UIColor = UIColor.blue {
7379
didSet {
7480
for textFieldView in textFieldViews {
7581
textFieldView.numberTextField.tintColor = textFieldTintColor
7682
}
7783
}
7884
}
85+
7986
@IBInspectable var darkKeyboard: Bool = false {
8087
didSet {
81-
if darkKeyboard {
82-
keyboardColor = .dark
83-
} else {
84-
keyboardColor = .light
85-
}
86-
88+
keyboardAppearance = darkKeyboard ? .dark : .light
8789
for textFieldView in textFieldViews {
88-
textFieldView.numberTextField.keyboardAppearance = keyboardColor
90+
textFieldView.numberTextField.keyboardAppearance = keyboardAppearance
8991
}
9092
}
9193
}
92-
93-
// MARK: - IBOutlets
94+
95+
// MARK: - IBOutlets
9496
@IBOutlet weak private var textFieldView1: KWTextFieldView!
9597
@IBOutlet weak private var textFieldView2: KWTextFieldView!
9698
@IBOutlet weak private var textFieldView3: KWTextFieldView!
9799
@IBOutlet weak private var textFieldView4: KWTextFieldView!
98100

99101
// MARK: - Variables
100-
private var keyboardColor = UIKeyboardAppearance.default
102+
private var keyboardAppearance = UIKeyboardAppearance.default
101103
private var textFieldFont = UIFont.systemFont(ofSize: 24.0)
102104

103105
lazy var textFieldViews: [KWTextFieldView] = {

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,45 @@ Add a `UIView` in your *Storyboard* and change the class to `KWVerificationCodeV
3131

3232
![Interface Builder Screenshot](Screenshots/interfacebuilder.png)
3333

34-
It is possile to set the default and selected colors of the underline in the *Storyboard*.
34+
The properties which can be directly set in the *Attributes Inspector* and their default values are as follows:
35+
36+
- `Underline Color` - Dark grey color
37+
38+
- `Underline Selected Color` - Black color
39+
40+
- `Text Color` - Dark text color
41+
42+
- `Text Size` - 24.0
43+
44+
- `Text Font` - System font
45+
46+
- `Text Field Background Color` - Clear color
47+
48+
- `Text Field Tint Color` - Blue color
49+
50+
- `Dark Keyboard` - Default keyboard apperance
3551

3652
### Methods
3753

38-
`hasValidCode() -> Bool` - Returns true when the entered code is valid.
54+
The `KWVerificationCodeView` has the following methods:
55+
56+
hasValidCode() -> Bool
57+
58+
Returns true when the entered code is valid.
59+
60+
getVerificationCode() -> String
61+
62+
Returns the validation code.
63+
64+
### Protocols
65+
66+
#### KWVerificationCodeViewDelegate
3967

40-
`getVerificationCode() -> String` - Returns the validation code.
68+
KWVerificationCodeViewDelegate protocol has the following method:
4169

42-
### Delegate
70+
didChangeVerificationCode()
4371

44-
`KWVerificationCodeViewDelegate` has a method `didChangeVerificationCode()`, which you can implement to check for valid code in real time. This comes handy in situations where you have to enable the submit button only if the verification code is valid.
72+
Notifies that the text in `KWVerificationCodeView` has been changed. This is especially useful in situations where you have to enable the submit button only if the verification code is valid.
4573

4674
## Author
4775

@@ -59,4 +87,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/keepwo
5987

6088
## License
6189

62-
KWVerificationCodeView is available under the MIT license. See the LICENSE file for more info.
90+
KWVerificationCodeView is available under the MIT license. See the LICENSE file for more info.

Screenshots/interfacebuilder.png

33.7 KB
Loading

0 commit comments

Comments
 (0)