PassWordSecureBtnV.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // PassWordSecureBtnV.m
  3. // westkissMob
  4. //
  5. // Created by 王猛 on 2022/9/6.
  6. //
  7. #import "PassWordSecureBtnV.h"
  8. @implementation PassWordSecureBtnV
  9. - (void)tt_setupViews{
  10. [self addSubview:self.xxx_passwordTF];
  11. [self addSubview:self.xxx_secureBtn];
  12. [self addSubview:self.xxx_warnLab];
  13. }
  14. -(void)xxx_changeSecure:(UIButton *)btn{
  15. btn.selected = !btn.selected;
  16. NSString *tmpPwd = self.xxx_passwordTF.text;
  17. self.xxx_passwordTF.text = nil;
  18. self.xxx_passwordTF.secureTextEntry = !self.xxx_passwordTF.secureTextEntry;
  19. self.xxx_passwordTF.text = tmpPwd;
  20. if (self.xxx_passwordTF.secureTextEntry) {
  21. [self.xxx_passwordTF resignFirstResponder];
  22. }
  23. }
  24. #pragma mark - UITextFieldDelegate
  25. - (void)textFieldDidBeginEditing:(UITextField *)textField {
  26. if (textField == self.xxx_passwordTF && self.xxx_passwordTF.secureTextEntry) {
  27. [self.xxx_passwordTF insertText:self.xxx_passwordTF.text];
  28. }
  29. self.xxx_warnLab.hidden = YES;
  30. }
  31. -(void)textFieldDidEndEditing:(UITextField *)textField{
  32. if (textField == self.xxx_passwordTF) {
  33. if (self.xxx_passwordTF.text.length<6) {
  34. self.xxx_warnLab.hidden = NO;
  35. }else{
  36. self.xxx_warnLab.hidden = YES;
  37. }
  38. }
  39. }
  40. -(TT_CustonTF *)xxx_passwordTF{
  41. if (!_xxx_passwordTF) {
  42. _xxx_passwordTF = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(0, 0, KScreenWidth-40, 50)
  43. PlaceHolder:@"* PASSWORD"
  44. andLifImage:nil
  45. AndRightImage:nil
  46. LiftImageFrame:CGRectZero
  47. RightImageFrame:CGRectZero
  48. AndTag:0
  49. AndKeyboardType:UIKeyboardTypeDefault
  50. clearButtonMode:UITextFieldViewModeNever
  51. AndReturnKeyType:UIReturnKeyDone
  52. masksToBounds:YES
  53. conrenRadius:4
  54. BorderColor:[UIColor colorWithHexString:@"#000000"]
  55. BorderWidth:1];
  56. _xxx_passwordTF.delegate = self;
  57. _xxx_passwordTF.secureTextEntry = YES;
  58. }
  59. return _xxx_passwordTF;
  60. }
  61. - (UIButton *)xxx_secureBtn{
  62. if (!_xxx_secureBtn) {
  63. _xxx_secureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  64. _xxx_secureBtn.frame = CGRectMake(KScreenWidth-40-50, 0,50 , 50);
  65. [_xxx_secureBtn setAttributedTitle:[[NSMutableAttributedString alloc] initWithString:@"VIEW"] forState:UIControlStateNormal];
  66. NSMutableAttributedString *attrSleStr = [[NSMutableAttributedString alloc] initWithString:@"VIEW" attributes:@{NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle)}];
  67. [_xxx_secureBtn setAttributedTitle:attrSleStr forState:UIControlStateSelected];
  68. [_xxx_secureBtn setTitleColor:[UIColor qmui_colorWithHexString:@"#000000"] forState:UIControlStateNormal];
  69. _xxx_secureBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:14];
  70. [_xxx_secureBtn addTarget:self action:@selector(xxx_changeSecure:) forControlEvents:UIControlEventTouchUpInside];
  71. _xxx_secureBtn.selected = NO;
  72. _xxx_secureBtn.backgroundColor = [UIColor clearColor];
  73. }
  74. return _xxx_secureBtn;
  75. }
  76. -(UILabel *)xxx_warnLab{
  77. if (!_xxx_warnLab) {
  78. _xxx_warnLab = [UILabel new];
  79. _xxx_warnLab.frame = CGRectMake(20, 50, KScreenWidth-40, 20);
  80. _xxx_warnLab.textColor = [UIColor colorWithHexString:@"#bf1221"];
  81. _xxx_warnLab.textAlignment = NSTextAlignmentCenter;
  82. _xxx_warnLab.backgroundColor= [UIColor clearColor];
  83. _xxx_warnLab.text = @"* 6 characters minimunm.";
  84. _xxx_warnLab.font = [UIFont systemFontOfSize:12];
  85. _xxx_warnLab.hidden = YES;
  86. }
  87. return _xxx_warnLab;
  88. }
  89. @end