8
8
9
9
import UIKit
10
10
11
- protocol DPOTPViewDelegate {
11
+ public protocol DPOTPViewDelegate {
12
12
func dpOTPViewAddText( _ text: String , at position: Int )
13
13
func dpOTPViewRemoveText( _ text: String , at position: Int )
14
14
func dpOTPViewChangePositionAt( _ position: Int )
15
15
func dpOTPViewBecomeFirstResponder( )
16
16
func dpOTPViewResignFirstResponder( )
17
17
}
18
18
19
- @IBDesignable class DPOTPView : UIView {
19
+ @IBDesignable public final class DPOTPView : UIView {
20
20
21
21
/** The number of textField that will be put in the DPOTPView */
22
- @IBInspectable var count : Int = 4
22
+ @IBInspectable public var count : Int = 4
23
23
24
24
/** Spaceing between textField in the DPOTPView */
25
- @IBInspectable var spacing : CGFloat = 8
25
+ @IBInspectable public var spacing : CGFloat = 8
26
26
27
27
/** Text color for the textField */
28
- @IBInspectable var textColorTextField : UIColor = UIColor . black
28
+ @IBInspectable public var textColorTextField : UIColor = UIColor . black
29
29
30
30
/** Text font for the textField */
31
- @IBInspectable var fontTextField : UIFont = UIFont . systemFont ( ofSize: 25 )
31
+ @IBInspectable public var fontTextField : UIFont = UIFont . systemFont ( ofSize: 25 )
32
32
33
33
/** Placeholder */
34
- @IBInspectable var placeholder : String = " "
34
+ @IBInspectable public var placeholder : String = " "
35
35
36
36
/** Placeholder text color for the textField */
37
- @IBInspectable var placeholderTextColor : UIColor = UIColor . gray
37
+ @IBInspectable public var placeholderTextColor : UIColor = UIColor . gray
38
38
39
39
/** Circle textField */
40
- @IBInspectable var isCircleTextField : Bool = false
40
+ @IBInspectable public var isCircleTextField : Bool = false
41
41
42
42
/** Allow only Bottom Line for the TextField */
43
- @IBInspectable var isBottomLineTextField : Bool = false
43
+ @IBInspectable public var isBottomLineTextField : Bool = false
44
44
45
45
/** Background color for the textField */
46
- @IBInspectable var backGroundColorTextField : UIColor = UIColor . clear
46
+ @IBInspectable public var backGroundColorTextField : UIColor = UIColor . clear
47
47
48
48
/** Border color for the TextField */
49
- @IBInspectable var borderColorTextField : UIColor ?
49
+ @IBInspectable public var borderColorTextField : UIColor ?
50
50
51
51
/** Border color for the TextField */
52
- @IBInspectable var selectedBorderColorTextField : UIColor ?
52
+ @IBInspectable public var selectedBorderColorTextField : UIColor ?
53
53
54
54
/** Border width for the TextField */
55
- @IBInspectable var borderWidthTextField : CGFloat = 0.0
55
+ @IBInspectable public var borderWidthTextField : CGFloat = 0.0
56
56
57
57
/** Border width for the TextField */
58
- @IBInspectable var selectedBorderWidthTextField : CGFloat = 0.0
58
+ @IBInspectable public var selectedBorderWidthTextField : CGFloat = 0.0
59
59
60
60
/** Corner radius for the TextField */
61
- @IBInspectable var cornerRadiusTextField : CGFloat = 0.0
61
+ @IBInspectable public var cornerRadiusTextField : CGFloat = 0.0
62
62
63
63
/** Tint/cursor color for the TextField */
64
- @IBInspectable var tintColorTextField : UIColor = UIColor . systemBlue
64
+ @IBInspectable public var tintColorTextField : UIColor = UIColor . systemBlue
65
65
66
66
/** Shadow Radius for the TextField */
67
- @IBInspectable var shadowRadiusTextField : CGFloat = 0.0
67
+ @IBInspectable public var shadowRadiusTextField : CGFloat = 0.0
68
68
69
69
/** Shadow Opacity for the TextField */
70
- @IBInspectable var shadowOpacityTextField : Float = 0.0
70
+ @IBInspectable public var shadowOpacityTextField : Float = 0.0
71
71
72
72
/** Shadow Offset Size for the TextField */
73
- @IBInspectable var shadowOffsetSizeTextField : CGSize = . zero
73
+ @IBInspectable public var shadowOffsetSizeTextField : CGSize = . zero
74
74
75
75
/** Shadow color for the TextField */
76
- @IBInspectable var shadowColorTextField : UIColor ?
76
+ @IBInspectable public var shadowColorTextField : UIColor ?
77
77
78
78
/** Dismiss keyboard with enter last character*/
79
- @IBInspectable var dismissOnLastEntry : Bool = false
79
+ @IBInspectable public var dismissOnLastEntry : Bool = false
80
80
81
81
/** Secure Text Entry*/
82
- @IBInspectable var isSecureTextEntry : Bool = false
82
+ @IBInspectable public var isSecureTextEntry : Bool = false
83
83
84
84
/** Hide cursor*/
85
- @IBInspectable var isCursorHidden : Bool = false
85
+ @IBInspectable public var isCursorHidden : Bool = false
86
86
87
87
/** Dark keyboard*/
88
- @IBInspectable var isDarkKeyboard : Bool = false
88
+ @IBInspectable public var isDarkKeyboard : Bool = false
89
89
90
- var textEdgeInsets : UIEdgeInsets ?
91
- var editingTextEdgeInsets : UIEdgeInsets ?
90
+ public var textEdgeInsets : UIEdgeInsets ?
91
+ public var editingTextEdgeInsets : UIEdgeInsets ?
92
92
93
- var dpOTPViewDelegate : DPOTPViewDelegate ?
94
- var keyboardType : UIKeyboardType = UIKeyboardType . asciiCapableNumberPad
93
+ public var dpOTPViewDelegate : DPOTPViewDelegate ?
94
+ public var keyboardType : UIKeyboardType = UIKeyboardType . asciiCapableNumberPad
95
95
96
- var text : String ? {
96
+ public var text : String ? {
97
97
get {
98
98
var str = " "
99
99
arrTextFields. forEach { str. append ( $0. text ?? " " ) }
@@ -113,22 +113,22 @@ protocol DPOTPViewDelegate {
113
113
fileprivate var arrTextFields : [ OTPBackTextField ] = [ ]
114
114
/** Override coder init, for IB/XIB compatibility */
115
115
#if !TARGET_INTERFACE_BUILDER
116
- required init ? ( coder aDecoder: NSCoder ) {
116
+ public required init ? ( coder aDecoder: NSCoder ) {
117
117
super. init ( coder: aDecoder)
118
118
}
119
119
120
120
/** Override common init, for manual allocation */
121
- override init ( frame: CGRect ) {
121
+ public override init ( frame: CGRect ) {
122
122
super. init ( frame: frame)
123
123
}
124
124
125
- override func layoutSubviews( ) {
125
+ public override func layoutSubviews( ) {
126
126
super. layoutSubviews ( )
127
127
self . initialization ( )
128
128
}
129
129
#endif
130
130
131
- override func prepareForInterfaceBuilder( ) {
131
+ public override func prepareForInterfaceBuilder( ) {
132
132
super. prepareForInterfaceBuilder ( )
133
133
initialization ( )
134
134
}
@@ -208,7 +208,7 @@ protocol DPOTPViewDelegate {
208
208
// }
209
209
210
210
211
- override func becomeFirstResponder( ) -> Bool {
211
+ public override func becomeFirstResponder( ) -> Bool {
212
212
if isCursorHidden {
213
213
for i in 0 ..< arrTextFields. count {
214
214
if arrTextFields [ i] . text? . count == 0 {
@@ -226,7 +226,7 @@ protocol DPOTPViewDelegate {
226
226
return super. becomeFirstResponder ( )
227
227
}
228
228
229
- override func resignFirstResponder( ) -> Bool {
229
+ public override func resignFirstResponder( ) -> Bool {
230
230
arrTextFields. forEach { ( textField) in
231
231
_ = textField. resignFirstResponder ( )
232
232
}
@@ -251,11 +251,11 @@ protocol DPOTPViewDelegate {
251
251
252
252
extension DPOTPView : UITextFieldDelegate , OTPBackTextFieldDelegate {
253
253
254
- func textFieldDidBeginEditing( _ textField: UITextField ) {
254
+ public func textFieldDidBeginEditing( _ textField: UITextField ) {
255
255
dpOTPViewDelegate? . dpOTPViewChangePositionAt ( textField. tag/ 1000 - 1 )
256
256
}
257
257
258
- func textField( _ textField: UITextField , shouldChangeCharactersIn range: NSRange , replacementString string: String ) -> Bool {
258
+ public func textField( _ textField: UITextField , shouldChangeCharactersIn range: NSRange , replacementString string: String ) -> Bool {
259
259
if string. trimmingCharacters ( in: CharacterSet . whitespaces) . count != 0 {
260
260
textField. text = string
261
261
if textField. tag < count*1000 {
0 commit comments