@@ -63,21 +63,26 @@ protocol DPOTPViewDelegate {
63
63
/** Tint/cursor color for the TextField */
64
64
@IBInspectable var tintColorTextField : UIColor = UIColor . systemBlue
65
65
66
+ /** Shadow Radius for the TextField */
67
+ @IBInspectable var shadowRadiusTextField : CGFloat = 0.0
68
+
69
+ /** Shadow Opacity for the TextField */
70
+ @IBInspectable var shadowOpacityTextField : Float = 0.0
71
+
72
+ /** Shadow Offset Size for the TextField */
73
+ @IBInspectable var shadowOffsetSizeTextField : CGSize = . zero
74
+
75
+ /** Shadow color for the TextField */
76
+ @IBInspectable var shadowColorTextField : UIColor ?
77
+
66
78
/** Dismiss keyboard with enter last character*/
67
79
@IBInspectable var dismissOnLastEntry : Bool = false
68
80
69
81
/** Secure Text Entry*/
70
82
@IBInspectable var isSecureTextEntry : Bool = false
71
83
72
84
/** Hide cursor*/
73
- @IBInspectable var isCursorHidden : Bool = false {
74
- didSet {
75
- if isCursorHidden {
76
- let tap = UITapGestureRecognizer ( target: self , action: #selector( self . handleTap ( _: ) ) )
77
- self . addGestureRecognizer ( tap)
78
- }
79
- }
80
- }
85
+ @IBInspectable var isCursorHidden : Bool = false
81
86
82
87
/** Dark keyboard*/
83
88
@IBInspectable var isDarkKeyboard : Bool = false
@@ -158,12 +163,17 @@ protocol DPOTPViewDelegate {
158
163
textField. layer. borderWidth = borderWidthTextField
159
164
if isCircleTextField {
160
165
textField. layer. cornerRadius = sizeTextField / 2
161
- textField. layer. masksToBounds = true
162
166
} else {
163
167
textField. layer. cornerRadius = cornerRadiusTextField
164
- textField. layer. masksToBounds = cornerRadiusTextField > 0.0
165
168
}
166
169
}
170
+ textField. layer. shadowRadius = shadowRadiusTextField
171
+ if let shadowColorTextField = shadowColorTextField {
172
+ textField. layer. shadowColor = shadowColorTextField. cgColor
173
+ }
174
+ textField. layer. shadowOpacity = shadowOpacityTextField
175
+ textField. layer. shadowOffset = shadowOffsetSizeTextField
176
+
167
177
textField. textColor = textColorTextField
168
178
textField. textAlignment = . center
169
179
textField. keyboardType = keyboardType
@@ -180,6 +190,13 @@ protocol DPOTPViewDelegate {
180
190
181
191
arrTextFields. append ( textField)
182
192
self . addSubview ( textField)
193
+ if isCursorHidden {
194
+ let tapView = UIView ( frame: self . bounds)
195
+ tapView. backgroundColor = . clear
196
+ let tap = UITapGestureRecognizer ( target: self , action: #selector( self . handleTap ( _: ) ) )
197
+ tapView. addGestureRecognizer ( tap)
198
+ self . addSubview ( tapView)
199
+ }
183
200
}
184
201
}
185
202
@@ -197,8 +214,9 @@ protocol DPOTPViewDelegate {
197
214
if arrTextFields [ i] . text? . count == 0 {
198
215
_ = arrTextFields [ i] . becomeFirstResponder ( )
199
216
break
200
- } else if ( arrTextFields. count - 1 ) == i{
217
+ } else if ( arrTextFields. count - 1 ) == i {
201
218
_ = arrTextFields [ i] . becomeFirstResponder ( )
219
+ break
202
220
}
203
221
}
204
222
} else {
@@ -234,10 +252,6 @@ protocol DPOTPViewDelegate {
234
252
extension DPOTPView : UITextFieldDelegate , OTPBackTextFieldDelegate {
235
253
236
254
func textFieldDidBeginEditing( _ textField: UITextField ) {
237
- if isCursorHidden {
238
- ( textField as? OTPBackTextField ) ? . addUnselectedBorderColor ( )
239
- _ = self . becomeFirstResponder ( )
240
- }
241
255
dpOTPViewDelegate? . dpOTPViewChangePositionAt ( textField. tag/ 1000 - 1 )
242
256
}
243
257
@@ -312,6 +326,13 @@ class OTPBackTextField: UITextField {
312
326
layer. borderColor = selectedBorderColor. cgColor
313
327
layer. borderWidth = dpOTPView. selectedBorderWidthTextField
314
328
}
329
+ } else {
330
+ if dpOTPView. isBottomLineTextField {
331
+ removePreviouslyAddedLayer ( name: " bottomBorderLayer " )
332
+ } else {
333
+ layer. borderColor = nil
334
+ layer. borderWidth = 0
335
+ }
315
336
}
316
337
}
317
338
@@ -323,6 +344,13 @@ class OTPBackTextField: UITextField {
323
344
layer. borderColor = unselectedBorderColor. cgColor
324
345
layer. borderWidth = dpOTPView. borderWidthTextField
325
346
}
347
+ } else {
348
+ if dpOTPView. isBottomLineTextField {
349
+ removePreviouslyAddedLayer ( name: " bottomBorderLayer " )
350
+ } else {
351
+ layer. borderColor = nil
352
+ layer. borderWidth = 0
353
+ }
326
354
}
327
355
}
328
356
0 commit comments