@@ -66,6 +66,7 @@ - (id)init
66
66
self = [super init ];
67
67
if (self)
68
68
{
69
+ self.alwaysGlowing = NO ;
69
70
[self _configureView ];
70
71
}
71
72
return self;
@@ -76,6 +77,7 @@ - (id)initWithFrame:(CGRect)frame
76
77
self = [super initWithFrame: frame];
77
78
if (self)
78
79
{
80
+ self.alwaysGlowing = NO ;
79
81
[self _configureView ];
80
82
}
81
83
return self;
@@ -86,6 +88,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
86
88
self = [super initWithCoder: aDecoder];
87
89
if (self)
88
90
{
91
+ self.alwaysGlowing = NO ;
89
92
[self _configureView ];
90
93
}
91
94
return self;
@@ -109,7 +112,7 @@ - (void)setBackgroundColor:(UIColor *)backgroundColor
109
112
110
113
- (void )setGlowingColor : (UIColor *)glowingColor
111
114
{
112
- if ([self isFirstResponder ]) {
115
+ if ([self isFirstResponder ] || self. alwaysGlowing ) {
113
116
[self animateBorderColorFrom: (id )self .layer.borderColor to: (id )glowingColor.CGColor shadowOpacityFrom: (id )[NSNumber numberWithFloat: 1 .f] to: (id )[NSNumber numberWithFloat: 1 .f]];
114
117
}
115
118
@@ -122,12 +125,23 @@ - (void)setBorderColor:(UIColor *)borderColor
122
125
{
123
126
_borderColor = borderColor;
124
127
125
- if (![self isFirstResponder ])
128
+ if (![self isFirstResponder ] && !self. alwaysGlowing )
126
129
{
127
130
self.layer .borderColor = self.borderColor .CGColor ;
128
131
}
129
132
}
130
133
134
+ - (void )setAlwaysGlowing : (BOOL )alwaysGlowing
135
+ {
136
+ if (_alwaysGlowing && !alwaysGlowing && ![self isFirstResponder ]) {
137
+ [self hideGlowing ];
138
+ } else if (!_alwaysGlowing && alwaysGlowing && ![self isFirstResponder ]) {
139
+ [self showGlowing ];
140
+ }
141
+
142
+ _alwaysGlowing = alwaysGlowing;
143
+ }
144
+
131
145
- (void )setFrame : (CGRect )frame
132
146
{
133
147
[super setFrame: frame];
@@ -167,9 +181,9 @@ - (BOOL)becomeFirstResponder
167
181
{
168
182
BOOL result = [super becomeFirstResponder ];
169
183
170
- if (result)
184
+ if (result && !self. alwaysGlowing )
171
185
{
172
- [self animateBorderColorFrom: ( id ) self .layer.borderColor to: ( id ) self .layer.shadowColor shadowOpacityFrom: ( id )[ NSNumber numberWithFloat: 0 .f] to: ( id )[ NSNumber numberWithFloat: 1 .f] ];
186
+ [self showGlowing ];
173
187
}
174
188
return result;
175
189
}
@@ -178,13 +192,23 @@ - (BOOL)resignFirstResponder
178
192
{
179
193
BOOL result = [super resignFirstResponder ];
180
194
181
- if (result)
195
+ if (result && !self. alwaysGlowing )
182
196
{
183
- [self animateBorderColorFrom: ( id ) self .layer.borderColor to: ( id ) self .borderColor. CGColor shadowOpacityFrom: ( id )[ NSNumber numberWithFloat: 1 .f] to: ( id )[ NSNumber numberWithFloat: 0 .f] ];
197
+ [self hideGlowing ];
184
198
}
185
199
return result;
186
200
}
187
201
202
+ - (void )showGlowing
203
+ {
204
+ [self animateBorderColorFrom: (id )self .layer.borderColor to: (id )self .layer.shadowColor shadowOpacityFrom: (id )[NSNumber numberWithFloat: 0 .f] to: (id )[NSNumber numberWithFloat: 1 .f]];
205
+ }
206
+
207
+ - (void )hideGlowing
208
+ {
209
+ [self animateBorderColorFrom: (id )self .layer.borderColor to: (id )self .borderColor.CGColor shadowOpacityFrom: (id )[NSNumber numberWithFloat: 1 .f] to: (id )[NSNumber numberWithFloat: 0 .f]];
210
+ }
211
+
188
212
- (CGRect )placeholderRectForBounds : (CGRect )bounds
189
213
{
190
214
return CGRectInset (bounds, 8 , 2 );
0 commit comments