inputPWDViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. //
  2. // inputPWDViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/10/12.
  6. //
  7. #import "inputPWDViewController.h"
  8. #import "connectDeviceManager.h"
  9. #import "RSATool.h"
  10. @interface inputPWDViewController (){
  11. NSString *pwd;
  12. UILabel *pointView0;
  13. UILabel *pointView1;
  14. UILabel *pointView2;
  15. UILabel *pointView3;
  16. }
  17. @property(nonatomic,strong)UILabel *pwdErrorTip;
  18. @end
  19. @implementation inputPWDViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view.
  23. pwd = @"";
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. [self.navigationBar setHidden:YES];
  28. [self.toolBar setHidden:YES];
  29. [self.view setBackgroundColor:HWF5F7FAColor];
  30. /*设置密码标题*/
  31. UILabel *topLabel = [[UILabel alloc] init];
  32. [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  33. [topLabel setTextColor:HW333333Color];
  34. [topLabel setTextAlignment:(NSTextAlignmentCenter)];
  35. [topLabel setText:NSLocalizedString(@"guide_input_pwd_title",nil)];
  36. [self.view addSubview:topLabel];
  37. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.mas_equalTo(20);
  39. make.right.mas_equalTo(-20);
  40. make.top.mas_equalTo(99.f + H_STATE_BAR);
  41. }];
  42. CGFloat w_pwd = 24.f;
  43. CGFloat h_pwd = 24.f;
  44. CGFloat pointFont = 20.f;
  45. /*密码视图*/
  46. pointView0 = [[UILabel alloc] init];
  47. [pointView0 setTextColor:HW0A132BColor];
  48. [pointView0 setBackgroundColor:HWE3E8F1Color];
  49. [pointView0 setClipsToBounds:YES];
  50. [pointView0 setTextAlignment:(NSTextAlignmentCenter)];
  51. [pointView0 setFont:[UIFont systemFontOfSize:pointFont]];
  52. [pointView0.layer setCornerRadius:w_pwd/2.f];
  53. [self.view addSubview:pointView0];
  54. [pointView0 mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.equalTo(self.view.mas_centerX).offset((0-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  56. make.height.mas_equalTo(h_pwd);
  57. make.width.mas_equalTo(w_pwd);
  58. make.top.mas_equalTo(151.f + H_STATE_BAR);
  59. }];
  60. pointView1 = [[UILabel alloc] init];
  61. [pointView1 setTextColor:HW0A132BColor];
  62. [pointView1 setBackgroundColor:HWE3E8F1Color];
  63. [pointView1 setClipsToBounds:YES];
  64. [pointView1 setTextAlignment:(NSTextAlignmentCenter)];
  65. [pointView1 setFont:[UIFont systemFontOfSize:pointFont]];
  66. [pointView1.layer setCornerRadius:w_pwd/2.f];
  67. [self.view addSubview:pointView1];
  68. [pointView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.equalTo(self.view.mas_centerX).offset((1-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  70. make.height.mas_equalTo(h_pwd);
  71. make.width.mas_equalTo(w_pwd);
  72. make.top.mas_equalTo(151.f + H_STATE_BAR);
  73. }];
  74. pointView2 = [[UILabel alloc] init];
  75. [pointView2 setTextColor:HW0A132BColor];
  76. [pointView2 setBackgroundColor:HWE3E8F1Color];
  77. [pointView2 setClipsToBounds:YES];
  78. [pointView2 setTextAlignment:(NSTextAlignmentCenter)];
  79. [pointView2 setFont:[UIFont systemFontOfSize:pointFont]];
  80. [pointView2.layer setCornerRadius:w_pwd/2.f];
  81. [self.view addSubview:pointView2];
  82. [pointView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.left.equalTo(self.view.mas_centerX).offset((2-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  84. make.height.mas_equalTo(h_pwd);
  85. make.width.mas_equalTo(w_pwd);
  86. make.top.mas_equalTo(151.f + H_STATE_BAR);
  87. }];
  88. pointView3 = [[UILabel alloc] init];
  89. [pointView3 setTextColor:HW0A132BColor];
  90. [pointView3 setBackgroundColor:HWE3E8F1Color];
  91. [pointView3 setClipsToBounds:YES];
  92. [pointView3 setTextAlignment:(NSTextAlignmentCenter)];
  93. [pointView3 setFont:[UIFont systemFontOfSize:pointFont]];
  94. [pointView3.layer setCornerRadius:w_pwd/2.f];
  95. [self.view addSubview:pointView3];
  96. [pointView3 mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.left.equalTo(self.view.mas_centerX).offset((3-2)*(w_pwd+w_pwd) + w_pwd/2.f);
  98. make.height.mas_equalTo(h_pwd);
  99. make.width.mas_equalTo(w_pwd);
  100. make.top.mas_equalTo(151.f + H_STATE_BAR);
  101. }];
  102. /*下方绘制键盘按钮*/
  103. UIView *bgViewForNumberBoard = [[UIView alloc] init];
  104. [bgViewForNumberBoard setBackgroundColor:[UIColor clearColor]];
  105. CGFloat w_bgViewForNumberBoard = SCREEN_W - 2*22.f*AUTOSCALE;
  106. CGFloat h_bgViewForNumberBoard = 330.f;
  107. [self.view addSubview:bgViewForNumberBoard];
  108. [bgViewForNumberBoard mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.left.mas_equalTo(22.f*AUTOSCALE);
  110. make.height.mas_equalTo(h_bgViewForNumberBoard);
  111. make.width.mas_equalTo(w_bgViewForNumberBoard);
  112. make.bottom.mas_equalTo(-70.f);
  113. }];
  114. CGFloat w_key_btn = w_bgViewForNumberBoard/3.f;
  115. CGFloat h_key_btn = h_bgViewForNumberBoard/4.f;
  116. /*绘制键盘 1~9*/
  117. for (NSInteger nFori = 0; nFori < 9; nFori++) {
  118. CGFloat x_key_btn = (nFori%3)*w_key_btn;
  119. CGFloat y_key_btn = (nFori/3)*h_key_btn;
  120. UIButton *keyBoardBtn = [[UIButton alloc] init];
  121. [keyBoardBtn setBackgroundColor:[UIColor clearColor]];
  122. [keyBoardBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  123. [keyBoardBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
  124. [keyBoardBtn setTitle:[NSString stringWithFormat:@"%ld",nFori+1] forState:(UIControlStateNormal)];
  125. [keyBoardBtn addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
  126. [bgViewForNumberBoard addSubview:keyBoardBtn];
  127. [keyBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.left.mas_equalTo(x_key_btn);
  129. make.top.mas_equalTo(y_key_btn);
  130. make.width.mas_equalTo(w_key_btn);
  131. make.height.mas_equalTo(h_key_btn);
  132. }];
  133. }
  134. /*删除按钮*/
  135. UIButton *deleteBoardBtn = [[UIButton alloc] init];
  136. [deleteBoardBtn setBackgroundColor:[UIColor clearColor]];
  137. [deleteBoardBtn addTarget:self action:@selector(deleteBoardBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
  138. [deleteBoardBtn setImage:[UIImage imageNamed:@"key_board_delete"] forState:(UIControlStateNormal)];
  139. [bgViewForNumberBoard addSubview:deleteBoardBtn];
  140. [deleteBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.left.mas_equalTo(0);
  142. make.bottom.mas_equalTo(0);
  143. make.width.mas_equalTo(w_key_btn);
  144. make.height.mas_equalTo(h_key_btn);
  145. }];
  146. /*0*/
  147. UIButton *keyBoardBtn0 = [[UIButton alloc] init];
  148. [keyBoardBtn0 setBackgroundColor:[UIColor clearColor]];
  149. [keyBoardBtn0 setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
  150. [keyBoardBtn0.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
  151. [keyBoardBtn0 setTitle:@"0" forState:(UIControlStateNormal)];
  152. [keyBoardBtn0 addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
  153. [bgViewForNumberBoard addSubview:keyBoardBtn0];
  154. [keyBoardBtn0 mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.left.mas_equalTo(w_key_btn);
  156. make.bottom.mas_equalTo(0);
  157. make.width.mas_equalTo(w_key_btn);
  158. make.height.mas_equalTo(h_key_btn);
  159. }];
  160. /*OK*/
  161. UIButton *keyBoardBtnOK = [[UIButton alloc] init];
  162. [keyBoardBtnOK setBackgroundColor:[UIColor clearColor]];
  163. [keyBoardBtnOK setTitleColor:HW13B2EBColor forState:(UIControlStateNormal)];
  164. [keyBoardBtnOK.titleLabel setFont:[UIFont boldSystemFontOfSize:30.f]];
  165. [keyBoardBtnOK setTitle:@"OK" forState:(UIControlStateNormal)];
  166. [keyBoardBtnOK addTarget:self action:@selector(keyBoardBtnOKPressed) forControlEvents:(UIControlEventTouchUpInside)];
  167. [bgViewForNumberBoard addSubview:keyBoardBtnOK];
  168. [keyBoardBtnOK mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.left.mas_equalTo(2*w_key_btn);
  170. make.bottom.mas_equalTo(0);
  171. make.width.mas_equalTo(w_key_btn);
  172. make.height.mas_equalTo(h_key_btn);
  173. }];
  174. /*绘制引导视图*/
  175. //[self addGuideView];
  176. }
  177. - (void)addGuideView{
  178. UIView *bgView = [[UIView alloc] init];
  179. [bgView setBackgroundColor:HW000000Color60];
  180. [self.view addSubview:bgView];
  181. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  182. make.left.mas_equalTo(0);
  183. make.bottom.mas_equalTo(0);
  184. make.right.mas_equalTo(0);
  185. make.top.mas_equalTo(0);
  186. }];
  187. /*密码背景*/
  188. UIView *pwdBgView = [[UIView alloc] init];
  189. [pwdBgView setBackgroundColor:HWF5F7FAColor];
  190. pwdBgView.layer.cornerRadius = 26.f;
  191. [bgView addSubview:pwdBgView];
  192. [pwdBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  193. make.centerX.equalTo(bgView.mas_centerX);
  194. make.top.mas_equalTo(68.f + H_STATE_BAR);
  195. make.width.mas_equalTo(248);
  196. make.height.mas_equalTo(138);
  197. }];
  198. /*密码*/
  199. UILabel *topLabel = [[UILabel alloc] init];
  200. [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
  201. [topLabel setTextColor:HW333333Color];
  202. [topLabel setTextAlignment:(NSTextAlignmentCenter)];
  203. [topLabel setText:NSLocalizedString(@"guide_set_pwd_title",nil)];
  204. [pwdBgView addSubview:topLabel];
  205. [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  206. make.left.mas_equalTo(20);
  207. make.right.mas_equalTo(-20);
  208. make.top.mas_equalTo(31.f);
  209. }];
  210. for (NSInteger nfori = 0; nfori < 4; nfori++) {
  211. CGFloat w_pwd = 24.f;
  212. CGFloat h_pwd = 24.f;
  213. /*密码视图*/
  214. UILabel *pointView = [[UILabel alloc] init];
  215. [pointView setBackgroundColor:HWE3E8F1Color];
  216. [pointView setClipsToBounds:YES];
  217. [pointView.layer setCornerRadius:w_pwd/2.f];
  218. [pwdBgView addSubview:pointView];
  219. [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.left.mas_equalTo(40.f + (w_pwd + w_pwd)*nfori);
  221. make.height.mas_equalTo(h_pwd);
  222. make.width.mas_equalTo(w_pwd);
  223. make.top.mas_equalTo(83.f);
  224. }];
  225. }
  226. /*箭头视图*/
  227. UIImageView *flagImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_set_pwd_flag"]];
  228. [bgView addSubview:flagImageView];
  229. [flagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  230. make.left.equalTo(pwdBgView.mas_left).offset(49);
  231. make.height.mas_equalTo(56);
  232. make.width.mas_equalTo(14);
  233. make.top.equalTo(pwdBgView.mas_bottom);
  234. }];
  235. /*不可点击btn*/
  236. UIButton *unableBtn = [[UIButton alloc] init];
  237. unableBtn.frame = CGRectMake(0, 0, 250, 40.f);
  238. // gradient
  239. CAGradientLayer *gl = [CAGradientLayer layer];
  240. gl.frame = CGRectMake(0,0,250,40.f);
  241. gl.startPoint = CGPointMake(0, 0.5);
  242. gl.endPoint = CGPointMake(1, 0.5);
  243. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  244. gl.locations = @[@(0), @(1.0f)];
  245. [unableBtn.layer addSublayer:gl];
  246. [unableBtn setUserInteractionEnabled:NO];
  247. [unableBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide",nil) forState:(UIControlStateNormal)];
  248. [unableBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  249. [unableBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  250. [unableBtn.layer setCornerRadius:8.f];
  251. unableBtn.clipsToBounds = YES;
  252. [bgView addSubview:unableBtn];
  253. [unableBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  254. make.left.equalTo(pwdBgView.mas_left).offset(16);
  255. make.width.mas_equalTo(250);
  256. make.top.equalTo(flagImageView.mas_bottom);
  257. make.height.mas_equalTo(40.f);
  258. }];
  259. UIButton *knowBtn = [[UIButton alloc] init];
  260. [knowBtn setBackgroundColor:[UIColor clearColor]];
  261. [knowBtn.layer setCornerRadius:18.f];
  262. [knowBtn.layer setBorderColor:HWFFFFFFColor.CGColor];
  263. [knowBtn.layer setBorderWidth:1];
  264. [knowBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:(UIControlStateNormal)];
  265. [knowBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  266. [knowBtn.titleLabel setFont:[UIFont systemFontOfSize:16]];
  267. [bgView addSubview:knowBtn];
  268. [knowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  269. make.right.equalTo(pwdBgView.mas_right).offset(-10);
  270. make.width.mas_equalTo(120);
  271. make.top.equalTo(unableBtn.mas_bottom).offset(25);
  272. make.height.mas_equalTo(36.f);
  273. }];
  274. [knowBtn addTarget:bgView
  275. action:@selector(removeFromSuperview)
  276. forControlEvents:(UIControlEventTouchUpInside)];
  277. }
  278. - (void)deleteBoardBtnPressed{
  279. if (pwd.length > 0){
  280. NSInteger numberLength = pwd.length;
  281. if (numberLength == 1){
  282. [pointView0 setText:@""];
  283. [pointView0 setBackgroundColor:HWE3E8F1Color];
  284. }else if (numberLength == 2){
  285. [pointView1 setText:@""];
  286. [pointView1 setBackgroundColor:HWE3E8F1Color];
  287. }else if (numberLength == 3){
  288. [pointView2 setText:@""];
  289. [pointView2 setBackgroundColor:HWE3E8F1Color];
  290. }else if (numberLength == 4){
  291. [pointView3 setText:@""];
  292. [pointView3 setBackgroundColor:HWE3E8F1Color];
  293. }
  294. pwd = [pwd substringToIndex:numberLength-1];
  295. }
  296. }
  297. - (void)keyBoardBtnOKPressed{
  298. if (pwd.length == 4){
  299. /*进入下一级推拉流界面*/
  300. [self verifyPwdFun:pwd];
  301. return;
  302. // //是否已经有密码了 有就是输入密码 没有就是设置密码
  303. // NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
  304. //
  305. // NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  306. //
  307. // if([desPwdStr isEqualToString:pwd]){
  308. // [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  309. // if(_isQRCodeType){
  310. // [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  311. // }
  312. //
  313. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  314. // [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
  315. // });
  316. //
  317. // //view 加载在windows上
  318. // [self.view removeFromSuperview];
  319. //
  320. // }
  321. // else{
  322. // [self deleteBoardBtnPressed];
  323. // [self deleteBoardBtnPressed];
  324. // [self deleteBoardBtnPressed];
  325. // [self deleteBoardBtnPressed];
  326. //
  327. // //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
  328. // //[[iToast makeText:@"111"] show];
  329. //
  330. // _pwdErrorTip = [[UILabel alloc] init];
  331. // _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil);
  332. // _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
  333. // _pwdErrorTip.textColor = [UIColor whiteColor];
  334. // _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
  335. // [self.view addSubview:_pwdErrorTip];
  336. //
  337. // _pwdErrorTip.layer.masksToBounds = YES;
  338. // _pwdErrorTip.layer.cornerRadius = 10;
  339. //
  340. // [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
  341. // make.center.mas_equalTo(0);
  342. // make.width.mas_equalTo(200);
  343. // make.height.mas_equalTo(40.f);
  344. // }];
  345. //
  346. // ///
  347. // [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
  348. //
  349. // [self->_pwdErrorTip removeFromSuperview];
  350. // self->_pwdErrorTip = nil;
  351. // }];
  352. // }
  353. }
  354. }
  355. #pragma mark 验证密码是否正确
  356. -(void)verifyPwdFun:(NSString*)text
  357. {
  358. /*先判断本地有无设备 无设备时需要先扫码添加设备*/
  359. NSDictionary *deviceDict = [HWDataManager getObjectWithKey:Const_Have_Add_Device];
  360. if (deviceDict && [[deviceDict allKeys] containsObject:Const_Have_Add_Device_SN]){
  361. //有设备了先去做链接准备 // 80bec9c5
  362. NSString *SNStr = deviceDict[@"Const_Have_Add_Device_SN"];
  363. if(SNStr){
  364. [[connectDeviceManager shareInstance] getThridMsgBySN:SNStr needReconnect:NO didNetEnd:^(bool didSuc) {
  365. if(didSuc){
  366. NSString *curPwd = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.password;
  367. NSString*desPwdStr = [RSATool AES128Decrypt:curPwd key:AESCODEKEEYY];
  368. if ([desPwdStr isEqualToString:text]){
  369. [self verifyPwdRightFun];
  370. }
  371. else{
  372. [self verifyPwdWrongFun:NO];
  373. }
  374. }
  375. else{
  376. [self verifyPwdWrongFun:YES];
  377. }
  378. }];
  379. }
  380. }
  381. }
  382. #pragma mark 验证密码正常
  383. -(void)verifyPwdRightFun
  384. {
  385. [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  386. if(_isQRCodeType){
  387. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  388. }
  389. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  390. [[NSNotificationCenter defaultCenter] postNotificationName:ShowImgAndVoiceNotification object:nil];
  391. });
  392. //view 加载在windows上
  393. [self.view removeFromSuperview];
  394. }
  395. #pragma mark 验证密码错误
  396. -(void)verifyPwdWrongFun:(BOOL)isNetFail
  397. {
  398. [self deleteBoardBtnPressed];
  399. [self deleteBoardBtnPressed];
  400. [self deleteBoardBtnPressed];
  401. [self deleteBoardBtnPressed];
  402. //[[iToast makeText:NSLocalizedString(@"logo_input_pwd_fail",nil)] show];
  403. //[[iToast makeText:@"111"] show];
  404. _pwdErrorTip = [[UILabel alloc] init];
  405. if(isNetFail){
  406. _pwdErrorTip.text = NSLocalizedString(@"log_login_system_busy",nil);
  407. }
  408. else{
  409. _pwdErrorTip.text = NSLocalizedString(@"logo_input_pwd_fail",nil);
  410. }
  411. _pwdErrorTip.textAlignment = NSTextAlignmentCenter;
  412. _pwdErrorTip.textColor = [UIColor whiteColor];
  413. _pwdErrorTip.backgroundColor = [UIColor hwColor:@"000000" alpha:0.7];
  414. [self.view addSubview:_pwdErrorTip];
  415. _pwdErrorTip.layer.masksToBounds = YES;
  416. _pwdErrorTip.layer.cornerRadius = 10;
  417. [_pwdErrorTip mas_makeConstraints:^(MASConstraintMaker *make) {
  418. make.center.mas_equalTo(0);
  419. make.width.mas_equalTo(200);
  420. make.height.mas_equalTo(40.f);
  421. }];
  422. ///
  423. [NSTimer scheduledTimerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
  424. [self->_pwdErrorTip removeFromSuperview];
  425. self->_pwdErrorTip = nil;
  426. }];
  427. }
  428. - (void)keyBoardBtnPressed:(id)sender{
  429. UIButton *btn = (UIButton *)sender;
  430. NSString *selectNumberStr = btn.titleLabel.text;
  431. if (pwd.length < 4){
  432. NSInteger numberLength = pwd.length;
  433. if (numberLength == 0){
  434. [pointView0 setText:selectNumberStr];
  435. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  436. [self->pointView0 setBackgroundColor:HW0A132BColor];
  437. });
  438. }else if (numberLength == 1){
  439. [pointView1 setText:selectNumberStr];
  440. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  441. [self->pointView1 setBackgroundColor:HW0A132BColor];
  442. });
  443. }else if (numberLength == 2){
  444. [pointView2 setText:selectNumberStr];
  445. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  446. [self->pointView2 setBackgroundColor:HW0A132BColor];
  447. });
  448. }else if (numberLength == 3){
  449. [pointView3 setText:selectNumberStr];
  450. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  451. [self->pointView3 setBackgroundColor:HW0A132BColor];
  452. [self keyBoardBtnOKPressed];
  453. });
  454. }
  455. pwd = [pwd stringByAppendingString:selectNumberStr];
  456. }
  457. }
  458. /*
  459. #pragma mark - Navigation
  460. // In a storyboard-based application, you will often want to do a little preparation before navigation
  461. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  462. // Get the new view controller using [segue destinationViewController].
  463. // Pass the selected object to the new view controller.
  464. }
  465. */
  466. @end