ASCustomAlertViewController.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. //
  2. // ASCustomAlertViewController.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/12/23.
  6. //
  7. #import "ASCustomAlertViewController.h"
  8. @interface ASCustomAlertViewController ()
  9. @property (nonatomic, assign) BOOL isMast;
  10. @end
  11. @implementation ASCustomAlertViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self configSubV];
  15. }
  16. - (void)setMastStatus:(BOOL)isMast {
  17. _isMast = isMast;
  18. self.cancelBt.hidden = isMast;
  19. self.closeBt.hidden = isMast;
  20. }
  21. - (void)configSubV {
  22. self.view.backgroundColor = UIColor.clearColor;
  23. [self.view addSubview:self.contentV];
  24. [self.contentV addSubview:self.closeBt];
  25. [self.contentV addSubview:self.conetntLb];
  26. [self.contentV addSubview:self.titleLb];
  27. [self.contentV addSubview:self.sureBt];
  28. [self.contentV addSubview:self.cancelBt];
  29. [self.conetntLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
  30. [self.contentV mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.center.equalTo(self.view);
  32. make.width.equalTo(@310);
  33. make.height.greaterThanOrEqualTo(@290);
  34. }];
  35. [self.closeBt mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.width.height.equalTo(@40);
  37. make.centerX.equalTo(self.contentV);
  38. make.top.equalTo(self.contentV).offset(22);
  39. }];
  40. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.equalTo(self.contentV).offset(18);
  42. make.right.equalTo(self.contentV).offset(-18);
  43. make.top.equalTo(self.closeBt.mas_bottom).offset(13);
  44. make.height.equalTo(@50);
  45. }];
  46. [self.sureBt mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.centerX.equalTo(self.contentV);
  48. make.width.equalTo(@120);
  49. make.height.equalTo(@35);
  50. make.bottom.equalTo(self.contentV).offset(-30);
  51. }];
  52. [self.cancelBt mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.bottom.equalTo(self.sureBt);
  54. make.height.equalTo(@35);
  55. make.left.equalTo(self.sureBt.mas_right).offset(15);
  56. make.right.equalTo(self.contentV).offset(-15);
  57. }];
  58. [self.conetntLb mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.left.equalTo(self.contentV).offset(18);
  60. make.right.equalTo(self.contentV).offset(-18);
  61. make.top.equalTo(self.titleLb.mas_bottom).offset(13);
  62. make.bottom.greaterThanOrEqualTo(self.sureBt.mas_top).offset(-30);
  63. }];
  64. }
  65. -(UIView *)contentV {
  66. if (!_contentV) {
  67. UIView * v = [[UIView alloc] init];
  68. v.backgroundColor = [UIColor colorWithHexString:@"#FFF5F0"];
  69. _contentV = v;
  70. }
  71. return _contentV;
  72. }
  73. - (UIButton *)closeBt {
  74. if (!_closeBt) {
  75. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  76. [btn setImage:[UIImage imageNamed:@"productLsit_filter_close"] forState:UIControlStateNormal];
  77. [btn addTarget:self action:@selector(closeBtAction) forControlEvents:UIControlEventTouchUpInside];
  78. _closeBt = btn;
  79. }
  80. return _closeBt;
  81. }
  82. - (UILabel *)conetntLb {
  83. if (!_conetntLb) {
  84. UILabel *lb = [[UILabel alloc] init];
  85. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  86. lb.textColor = [UIColor blackColor];
  87. lb.numberOfLines = 0;
  88. lb.text = @"A New Version Of West Kiss Upgrade Version 1.1.0 Is Available For Your Phone And Is Ready To Install Now!";
  89. lb.textAlignment = NSTextAlignmentCenter;
  90. lb.backgroundColor = [UIColor clearColor];
  91. lb.qmui_lineHeight = 24;
  92. _conetntLb = lb;
  93. }
  94. return _conetntLb;
  95. }
  96. - (UILabel *)titleLb {
  97. if (!_titleLb) {
  98. UILabel *lb = [[UILabel alloc] init];
  99. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  100. lb.qmui_lineHeight = 24;
  101. lb.textColor = [UIColor blackColor];
  102. lb.text = @"Update App?";
  103. lb.textAlignment = NSTextAlignmentCenter;
  104. lb.backgroundColor = [UIColor clearColor];
  105. _titleLb = lb;
  106. }
  107. return _titleLb;
  108. }
  109. - (UIButton *)sureBt {
  110. if (!_sureBt) {
  111. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  112. btn.backgroundColor = [UIColor blackColor];
  113. [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  114. [btn setTitle:@"UPDATE NOW" forState:UIControlStateNormal];
  115. btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  116. [btn addTarget:self action:@selector(sureBtAction) forControlEvents:UIControlEventTouchUpInside];
  117. _sureBt = btn;
  118. }
  119. return _sureBt;
  120. }
  121. - (UIButton *)cancelBt {
  122. if (!_cancelBt) {
  123. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  124. btn.backgroundColor = [UIColor clearColor];
  125. [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  126. NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"LATER"];
  127. [attStr setAttributes:@{
  128. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:16],
  129. NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle],
  130. NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
  131. NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"]
  132. } range:NSMakeRange(0, attStr.length)];
  133. [btn setAttributedTitle:attStr forState:UIControlStateNormal];
  134. [btn addTarget:self action:@selector(cancelBtAction) forControlEvents:UIControlEventTouchUpInside];
  135. _cancelBt = btn;
  136. }
  137. return _cancelBt;
  138. }
  139. - (void)sureBtAction {
  140. if (self.sureAction) {
  141. self.sureAction();
  142. }
  143. if (!_isMast) {
  144. ASWindowManager.share.customW = nil;
  145. }
  146. }
  147. - (void)cancelBtAction {
  148. if (self.cancelAction) {
  149. self.cancelAction();
  150. }
  151. ASWindowManager.share.customW = nil;
  152. }
  153. - (void)closeBtAction {
  154. if (self.closeAction) {
  155. self.closeAction();
  156. }
  157. ASWindowManager.share.customW = nil;
  158. }
  159. @end