@@ -51,7 +51,7 @@ - (instancetype)init{
5151
5252@interface JHVerificationCodeView ()
5353@property (strong , nonatomic ) JHVCConfig *config;
54- @property (strong , nonatomic ) UITextView *textView;
54+ @property (strong , nonatomic ) UITextField *textView;
5555@property (nonatomic , assign ) BOOL inputFinish;
5656@property (nonatomic , assign ) NSUInteger inputFinishIndex;
5757@end
@@ -183,14 +183,18 @@ - (void)jhSetupViews:(CGRect)frame
183183 [[UITapGestureRecognizer alloc ]initWithTarget:self action: @selector (xx_tap )];
184184 })];
185185
186- _textView = [[UITextView alloc ] init ];
186+ _textView = [[UITextField alloc ] init ];
187187 _textView.frame = CGRectMake (0 , CGRectGetHeight (frame), 0 , 0 );
188188 _textView.secureTextEntry = _config.useSystemPasswordKeyboard ;
189189 _textView.keyboardType = _config.keyboardType ;
190+ _textView.hidden = YES ;
191+ if (@available (iOS 12.0 , *)) {
192+ _textView.textContentType = UITextContentTypeOneTimeCode;
193+ }
190194 [self addSubview: _textView];
191195
192- [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (xx_textChange: ) name: UITextViewTextDidChangeNotification object: _textView];
193- [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (xx_didBecomeActive ) name: UIApplicationDidBecomeActiveNotification object: nil ];
196+ [[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (xx_textChange: ) name: UITextFieldTextDidChangeNotification object: _textView];
197+ // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(xx_didBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
194198
195199 if (_config.autoShowKeyboard ) {
196200 dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
@@ -205,6 +209,7 @@ - (CABasicAnimation *)xx_alphaAnimation{
205209 alpha.toValue = @(0.0 );
206210 alpha.duration = 1.0 ;
207211 alpha.repeatCount = CGFLOAT_MAX;
212+ alpha.removedOnCompletion = NO ;
208213 alpha.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut ];
209214 return alpha;
210215}
0 commit comments