YOUPAILZChatRoomUpLockWindow.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // YOUPAILZChatRoomUpLockWindow.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/11/10.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomUpLockWindow.h"
  9. #import "NNValidationCodeView.h"
  10. @interface YOUPAILZChatRoomUpLockWindow ()
  11. @property (nonatomic,strong)NSString *youpaippassword;
  12. @end
  13. @implementation YOUPAILZChatRoomUpLockWindow
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.baseView.hidden = YES;
  17. [self youpaifinitUI];
  18. }
  19. - (void)youpaifinitUI{
  20. UIView *bgV = [[UIView alloc] init];
  21. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  22. bgV.layer.cornerRadius = 10.0f;
  23. bgV.clipsToBounds = YES;
  24. bgV.layer.borderColor = HexColorFromRGB(0x4F4B5B).CGColor;
  25. bgV.layer.borderWidth = 0.5f;
  26. [self.view addSubview:bgV];
  27. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.offset(ScaleSize(32.0f));
  29. make.centerY.equalTo(self.view);
  30. make.right.offset(-ScaleSize(32.0f));
  31. make.height.offset(ScaleSize(230.0f));
  32. }];
  33. UILabel *titleL = [[UILabel alloc] init];
  34. titleL.text = @"房间上锁";
  35. titleL.textColor = [UIColor whiteColor];
  36. titleL.font = LCBoldFont(19.0f);
  37. [bgV addSubview:titleL];
  38. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.offset(20.0f);
  40. make.height.offset(22.0f);
  41. make.centerX.equalTo(bgV);
  42. }];
  43. UILabel *descL = [[UILabel alloc] init];
  44. descL.textAlignment = NSTextAlignmentCenter;
  45. descL.text = @"请输入4位数字密码";
  46. descL.font = LCFont(14.0f);
  47. descL.textColor = [UIColor whiteColor];
  48. [bgV addSubview:descL];
  49. [descL mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(titleL.mas_bottom).offset(14.0f);
  51. make.height.offset(20.0f);
  52. make.centerX.equalTo(bgV);
  53. }];
  54. [bgV layoutIfNeeded];
  55. NNValidationCodeView *view = [[NNValidationCodeView alloc] initWithFrame:CGRectMake(ScaleSize(40.0f), CGRectGetMaxY(descL.frame) + ScaleSize(18.0f), KScreenWidth - ScaleSize(32.0f) * 2.0f - ScaleSize(40.0f) * 2.0f, ScaleSize(46.0f)) andLabelCount:4 andLabelDistance:ScaleSize(16.0f)];
  56. view.defaultColor = HexColorFromRGB(0x5D5987);
  57. view.changedColor = HexColorFromRGB(0xFF3065);
  58. view.itemCornerRadius = ScaleSize(10.0f);
  59. [view.codeTextField becomeFirstResponder];
  60. [bgV addSubview:view];
  61. @weakify(self);
  62. view.codeBlock = ^(NSString *codeString) {
  63. @strongify(self);
  64. self.youpaippassword = codeString;
  65. };
  66. CGFloat btnWidth = (KScreenWidth - 90.0f - 15.0f) / 2.0f;
  67. UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  68. [cancelBtn addTarget:self action:@selector(youpaifcancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
  69. [cancelBtn setTitle:@"取消" forState:0];
  70. [cancelBtn setTitleColor:HexColorFromRGB(0xffffff) forState:0];
  71. [cancelBtn setBackgroundColor:HexColorFromRGB(0x4F4B5B)];
  72. cancelBtn.layer.cornerRadius = 24.0f;
  73. cancelBtn.clipsToBounds = YES;
  74. cancelBtn.titleLabel.font = LCFont(17);
  75. [bgV addSubview:cancelBtn];
  76. [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.bottom.offset(-20.0f);
  78. make.left.offset(14.0f);
  79. make.size.mas_offset(CGSizeMake(btnWidth, 48.0f));
  80. }];
  81. UIButton *youpaipconfirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  82. [youpaipconfirmBtn addTarget:self action:@selector(youpaifconfirmBtnAction) forControlEvents:UIControlEventTouchUpInside];
  83. [youpaipconfirmBtn setTitle:@"确定" forState:0];
  84. [youpaipconfirmBtn setTitleColor:HexColorFromRGB(0xffffff) forState:0];
  85. [youpaipconfirmBtn setBackgroundColor:[UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake(btnWidth, 48) FromColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] ByGradientType:GradientLeftToRight]]];
  86. youpaipconfirmBtn.layer.cornerRadius = 24.0f;
  87. youpaipconfirmBtn.clipsToBounds = YES;
  88. youpaipconfirmBtn.titleLabel.font = LCFont(17);
  89. [bgV addSubview:youpaipconfirmBtn];
  90. [youpaipconfirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.bottom.offset(-20.0f);
  92. make.right.offset(-14.0f);
  93. make.size.mas_offset(CGSizeMake(btnWidth, 48.0f));
  94. }];
  95. }
  96. - (void)youpaifcancelBtnAction{
  97. [self dismissViewControllerAnimated:YES completion:^{}];
  98. }
  99. - (void)youpaifconfirmBtnAction{
  100. if (self.youpaippassword.length == 4) {
  101. [self dismissViewControllerAnimated:YES completion:^{
  102. if (self.youpaipconfirmBtnClickBlock != nil) {
  103. self.youpaipconfirmBtnClickBlock(self.youpaippassword);
  104. }
  105. }];
  106. }
  107. }
  108. @end