YMOpenAdolescentModelPopupView.m 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // YMOpenAdolescentModelPopupView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/22.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMOpenAdolescentModelPopupView.h"
  9. @interface YMOpenAdolescentModelPopupView ()
  10. /// 青少年模式提示图片视图
  11. @property (nonatomic, strong) UIImageView *adolescentModelImageView;
  12. /// 青少年模式状态标签
  13. @property (nonatomic, strong) UILabel *adolescentModelStatusLb;
  14. /// 不再提示按钮
  15. @property (nonatomic, strong) UIButton *noMoreRemindersBtn;
  16. /// 进入青少年模式按钮
  17. @property (nonatomic, strong) UIButton *gotoAdolescentModelBtn;
  18. @end
  19. @implementation YMOpenAdolescentModelPopupView
  20. - (void)ym_setupViews{
  21. self.backgroundColor = UIColor.whiteColor;
  22. [self addSubview:self.adolescentModelImageView];
  23. [self addSubview:self.adolescentModelStatusLb];
  24. [self addSubview:self.noMoreRemindersBtn];
  25. [self addSubview:self.gotoAdolescentModelBtn];
  26. [self setNeedsUpdateConstraints];
  27. [self updateConstraintsIfNeeded];
  28. [self configurationAdolescentModel];
  29. }
  30. - (void)updateConstraints{
  31. [self.adolescentModelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.centerX.equalTo(self.mas_centerX);
  33. make.top.equalTo(self).offset(adapt(20));
  34. make.width.mas_equalTo(adapt(220));
  35. make.height.mas_equalTo(adapt(220));
  36. }];
  37. [self.adolescentModelStatusLb mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(self.adolescentModelImageView.mas_bottom).offset(adapt(10));
  39. make.left.equalTo(self).offset(adapt(15));
  40. make.right.equalTo(self).offset(adapt(-15));
  41. }];
  42. [self.noMoreRemindersBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.top.equalTo(self.adolescentModelStatusLb.mas_bottom).offset(adapt(15));
  44. make.left.equalTo(self).offset(adapt(15));
  45. make.right.equalTo(self).offset(adapt(-15));
  46. make.height.mas_equalTo(adapt(55));
  47. }];
  48. [self.gotoAdolescentModelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.centerX.equalTo(self.noMoreRemindersBtn.mas_centerX);
  50. make.top.equalTo(self.noMoreRemindersBtn.mas_bottom).offset(adapt(10));
  51. make.width.mas_equalTo(adapt(90));
  52. make.height.mas_equalTo(adapt(30));
  53. make.bottom.equalTo(self).offset(adapt(-20));
  54. }];
  55. [super updateConstraints];
  56. }
  57. - (void)configurationAdolescentModel{
  58. CGFloat adolescentModelImageViewHeight = [self.adolescentModelImageView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  59. CGFloat adolescentModelStatusLbHeight = [self.adolescentModelStatusLb systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  60. CGFloat noMoreRemindersBtnHeight = [self.noMoreRemindersBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  61. CGFloat gotoAdolescentModelBtnHeight = [self.gotoAdolescentModelBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  62. self.frame = CGRectMake(0, 0, kFrameWidth*0.88, adapt(20) + adolescentModelImageViewHeight + adapt(15) + adolescentModelStatusLbHeight + adapt(15) + noMoreRemindersBtnHeight + adapt(10) + gotoAdolescentModelBtnHeight + adapt(20));
  63. }
  64. - (UIImageView *)adolescentModelImageView{
  65. if (!_adolescentModelImageView) {
  66. _adolescentModelImageView = [[UIImageView alloc]init];
  67. _adolescentModelImageView.image = ImageByName(@"ym_common_adolescent_model_tips_one_icon");
  68. }
  69. return _adolescentModelImageView;
  70. }
  71. - (UILabel *)adolescentModelStatusLb{
  72. if (!_adolescentModelStatusLb) {
  73. _adolescentModelStatusLb = [[UILabel alloc]init];
  74. _adolescentModelStatusLb.font = LCFont(15);
  75. _adolescentModelStatusLb.textColor = HexColorFromRGB(0x333333);
  76. _adolescentModelStatusLb.textAlignment = NSTextAlignmentCenter;
  77. _adolescentModelStatusLb.text = @"为呵护未成年人健康成长\n我们已推出青少年";
  78. _adolescentModelStatusLb.numberOfLines = 0;
  79. }
  80. return _adolescentModelStatusLb;
  81. }
  82. - (UIButton *)noMoreRemindersBtn{
  83. if (!_noMoreRemindersBtn) {
  84. _noMoreRemindersBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  85. _noMoreRemindersBtn.titleLabel.font = LCFont(12);
  86. [_noMoreRemindersBtn setTitle:@"不再提示" forState:UIControlStateNormal];
  87. [_noMoreRemindersBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  88. [_noMoreRemindersBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  89. _noMoreRemindersBtn.layer.cornerRadius = adapt(55) / 2.0;
  90. _noMoreRemindersBtn.layer.masksToBounds = YES;
  91. WS(weakSelf)
  92. [[[_noMoreRemindersBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  93. if (weakSelf.noMoreRemindersButtonBlock) {
  94. weakSelf.noMoreRemindersButtonBlock();
  95. }
  96. }];
  97. }
  98. return _noMoreRemindersBtn;
  99. }
  100. - (UIButton *)gotoAdolescentModelBtn{
  101. if (!_gotoAdolescentModelBtn) {
  102. _gotoAdolescentModelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  103. _gotoAdolescentModelBtn.titleLabel.font = LCFont(12);
  104. [_gotoAdolescentModelBtn setTitle:@"进入青少年模式" forState:UIControlStateNormal];
  105. [_gotoAdolescentModelBtn setTitleColor:HexColorFromRGB(0x9c9c9c) forState:UIControlStateNormal];
  106. WS(weakSelf)
  107. [[[_gotoAdolescentModelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  108. if (weakSelf.gotoAdolescentModelButtonBlock) {
  109. weakSelf.gotoAdolescentModelButtonBlock();
  110. }
  111. }];
  112. }
  113. return _gotoAdolescentModelBtn;
  114. }
  115. @end