123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // YMAdolescentModelPopupView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/22.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMCloseAdolescentModelPopupView.h"
- @interface YMCloseAdolescentModelPopupView ()
- /// 青少年模式提示图片视图
- @property (nonatomic, strong) UIImageView *adolescentModelImageView;
- /// 青少年模式状态标签
- @property (nonatomic, strong) UILabel *adolescentModelStatusLb;
- /// 开启或关闭青少年模式按钮
- @property (nonatomic, strong) UIButton *openOrCloseAdolescentModelBtn;
- /// 忘记密码按钮
- @property (nonatomic, strong) UIButton *forgotPasswordBtn;
- @end
- @implementation YMCloseAdolescentModelPopupView
- - (void)ym_setupViews{
- self.backgroundColor = UIColor.whiteColor;
-
- [self addSubview:self.adolescentModelImageView];
- [self addSubview:self.adolescentModelStatusLb];
- [self addSubview:self.openOrCloseAdolescentModelBtn];
- [self addSubview:self.forgotPasswordBtn];
- [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(15));
- make.left.equalTo(self).offset(adapt(15));
- make.right.equalTo(self).offset(adapt(-15));
- }];
-
- [self.openOrCloseAdolescentModelBtn 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(50));
- }];
-
- [self.forgotPasswordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.openOrCloseAdolescentModelBtn.mas_centerX);
- make.top.equalTo(self.openOrCloseAdolescentModelBtn.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 openOrCloseAdolescentModelBtnHeight = [self.openOrCloseAdolescentModelBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
-
- CGFloat forgotPasswordBtnHeight = [self.forgotPasswordBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
-
- self.frame = CGRectMake(0, 0, kFrameWidth*0.88, adapt(20) + adolescentModelImageViewHeight + adapt(15) + adolescentModelStatusLbHeight + adapt(15) + openOrCloseAdolescentModelBtnHeight + adapt(10) + forgotPasswordBtnHeight + adapt(20));
- }
- - (UIImageView *)adolescentModelImageView{
- if (!_adolescentModelImageView) {
- _adolescentModelImageView = [[UIImageView alloc]init];
- _adolescentModelImageView.image = ImageByName(@"ym_common_adolescent_model_tips_two_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 *)openOrCloseAdolescentModelBtn{
- if (!_openOrCloseAdolescentModelBtn) {
- _openOrCloseAdolescentModelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _openOrCloseAdolescentModelBtn.titleLabel.font = LCFont(12);
- [_openOrCloseAdolescentModelBtn setTitle:@"关闭未成年模式" forState:UIControlStateNormal];
- [_openOrCloseAdolescentModelBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
- _openOrCloseAdolescentModelBtn.backgroundColor = HexColorFromRGB(0xfd7bc5);
- _openOrCloseAdolescentModelBtn.layer.cornerRadius = adapt(8);
- _openOrCloseAdolescentModelBtn.layer.masksToBounds = YES;
- WS(weakSelf)
- [[[_openOrCloseAdolescentModelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- if (weakSelf.openOrCloseAdolescentModelButtonBlock) {
- weakSelf.openOrCloseAdolescentModelButtonBlock();
- }
- }];
- }
- return _openOrCloseAdolescentModelBtn;
- }
- - (UIButton *)forgotPasswordBtn{
- if (!_forgotPasswordBtn) {
- _forgotPasswordBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _forgotPasswordBtn.titleLabel.font = LCFont(12);
- [_forgotPasswordBtn setTitle:@"忘记密码" forState:UIControlStateNormal];
- [_forgotPasswordBtn setTitleColor:HexColorFromRGB(0x9c9c9c) forState:UIControlStateNormal];
- WS(weakSelf)
- [[[_forgotPasswordBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- if (weakSelf.forgotPasswordBlock) {
- weakSelf.forgotPasswordBlock();
- }
- }];
- }
- return _forgotPasswordBtn;
- }
- @end
|