// // YMOpenAdolescentModelPopupView.m // MSYOUPAI // // Created by YoMi on 2024/2/22. // Copyright © 2024 MS. All rights reserved. // #import "YMOpenAdolescentModelPopupView.h" @interface YMOpenAdolescentModelPopupView () /// 青少年模式提示图片视图 @property (nonatomic, strong) UIImageView *adolescentModelImageView; /// 青少年模式状态标签 @property (nonatomic, strong) UILabel *adolescentModelStatusLb; /// 不再提示按钮 @property (nonatomic, strong) UIButton *noMoreRemindersBtn; /// 进入青少年模式按钮 @property (nonatomic, strong) UIButton *gotoAdolescentModelBtn; @end @implementation YMOpenAdolescentModelPopupView - (void)ym_setupViews{ self.backgroundColor = UIColor.whiteColor; [self addSubview:self.adolescentModelImageView]; [self addSubview:self.adolescentModelStatusLb]; [self addSubview:self.noMoreRemindersBtn]; [self addSubview:self.gotoAdolescentModelBtn]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; [self configurationAdolescentModel]; } - (void)updateConstraints{ [self.adolescentModelImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.mas_centerX); make.top.equalTo(self).offset(adapt(20)); make.width.mas_equalTo(adapt(220)); make.height.mas_equalTo(adapt(220)); }]; [self.adolescentModelStatusLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.adolescentModelImageView.mas_bottom).offset(adapt(10)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); }]; [self.noMoreRemindersBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.adolescentModelStatusLb.mas_bottom).offset(adapt(15)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); make.height.mas_equalTo(adapt(55)); }]; [self.gotoAdolescentModelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.noMoreRemindersBtn.mas_centerX); make.top.equalTo(self.noMoreRemindersBtn.mas_bottom).offset(adapt(10)); make.width.mas_equalTo(adapt(90)); make.height.mas_equalTo(adapt(30)); make.bottom.equalTo(self).offset(adapt(-20)); }]; [super updateConstraints]; } - (void)configurationAdolescentModel{ CGFloat adolescentModelImageViewHeight = [self.adolescentModelImageView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; CGFloat adolescentModelStatusLbHeight = [self.adolescentModelStatusLb systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; CGFloat noMoreRemindersBtnHeight = [self.noMoreRemindersBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; CGFloat gotoAdolescentModelBtnHeight = [self.gotoAdolescentModelBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; self.frame = CGRectMake(0, 0, kFrameWidth*0.88, adapt(20) + adolescentModelImageViewHeight + adapt(15) + adolescentModelStatusLbHeight + adapt(15) + noMoreRemindersBtnHeight + adapt(10) + gotoAdolescentModelBtnHeight + adapt(20)); } - (UIImageView *)adolescentModelImageView{ if (!_adolescentModelImageView) { _adolescentModelImageView = [[UIImageView alloc]init]; _adolescentModelImageView.image = ImageByName(@"ym_common_adolescent_model_tips_one_icon"); } return _adolescentModelImageView; } - (UILabel *)adolescentModelStatusLb{ if (!_adolescentModelStatusLb) { _adolescentModelStatusLb = [[UILabel alloc]init]; _adolescentModelStatusLb.font = LCFont(15); _adolescentModelStatusLb.textColor = HexColorFromRGB(0x333333); _adolescentModelStatusLb.textAlignment = NSTextAlignmentCenter; _adolescentModelStatusLb.text = @"为呵护未成年人健康成长\n我们已推出青少年"; _adolescentModelStatusLb.numberOfLines = 0; } return _adolescentModelStatusLb; } - (UIButton *)noMoreRemindersBtn{ if (!_noMoreRemindersBtn) { _noMoreRemindersBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _noMoreRemindersBtn.titleLabel.font = LCFont(12); [_noMoreRemindersBtn setTitle:@"不再提示" forState:UIControlStateNormal]; [_noMoreRemindersBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal]; [_noMoreRemindersBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP]; _noMoreRemindersBtn.layer.cornerRadius = adapt(55) / 2.0; _noMoreRemindersBtn.layer.masksToBounds = YES; WS(weakSelf) [[[_noMoreRemindersBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if (weakSelf.noMoreRemindersButtonBlock) { weakSelf.noMoreRemindersButtonBlock(); } }]; } return _noMoreRemindersBtn; } - (UIButton *)gotoAdolescentModelBtn{ if (!_gotoAdolescentModelBtn) { _gotoAdolescentModelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _gotoAdolescentModelBtn.titleLabel.font = LCFont(12); [_gotoAdolescentModelBtn setTitle:@"进入青少年模式" forState:UIControlStateNormal]; [_gotoAdolescentModelBtn setTitleColor:HexColorFromRGB(0x9c9c9c) forState:UIControlStateNormal]; WS(weakSelf) [[[_gotoAdolescentModelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if (weakSelf.gotoAdolescentModelButtonBlock) { weakSelf.gotoAdolescentModelButtonBlock(); } }]; } return _gotoAdolescentModelBtn; } @end