// // YMImproveInfoAgeView.m // MSYOUPAI // // Created by YoMi on 2024/2/8. // Copyright © 2024 MS. All rights reserved. // #import "YMImproveInfoAgeView.h" #import "YMImproveInfoViewModel.h" @interface YMImproveInfoAgeView () /// 完善信息VM @property (nonatomic, strong) YMImproveInfoViewModel *viewModel; /// 年龄标题标签 @property (nonatomic, strong) UILabel *ageTitleLb; /// 年龄内容标签 @property (nonatomic, strong) UILabel *ageContentLb; @property (nonatomic, strong) UIView *baseView; @property (nonatomic, strong) UIImageView *rightImgV; @end @implementation YMImproveInfoAgeView - (void)ym_setupViews{ [self addSubview:self.ageTitleLb]; [self addSubview:self.baseView]; [self.baseView addSubview:self.ageContentLb]; [self.baseView addSubview:self.rightImgV]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints{ [self.ageTitleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self); make.left.equalTo(self); make.height.mas_equalTo(adapt(25)); }]; [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.ageTitleLb.mas_bottom); make.left.equalTo(self); make.right.equalTo(self); make.height.mas_equalTo(adapt(50)); }]; [self.ageContentLb mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.baseView); make.left.equalTo(self.baseView).offset(adapt(16)); }]; [self.rightImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.baseView); make.right.equalTo(self.baseView).offset(adapt(-16)); make.width.mas_equalTo(adapt(16)); make.height.mas_equalTo(adapt(16)); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMImproveInfoViewModel *)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; RAC(self.ageContentLb, text) = RACObserve(self.viewModel, improveInfoAge); } - (UIView *)baseView{ if (!_baseView) { _baseView = [[UIView alloc]init]; _baseView.backgroundColor = UIColor.whiteColor; _baseView.layer.borderColor = HexColorFromRGBA(0x1000000,0.17).CGColor; _baseView.layer.borderWidth = 1; _baseView.layer.cornerRadius = adapt(11); _baseView.layer.masksToBounds = true; } return _baseView; } - (UIImageView *)rightImgV{ if (!_rightImgV) { _rightImgV = [[UIImageView alloc]init]; _rightImgV.userInteractionEnabled = true; _rightImgV.image = ImageByName(@"ym_improve_info_right_icon"); } return _rightImgV; } - (UILabel *)ageTitleLb{ if (!_ageTitleLb) { _ageTitleLb = [[UILabel alloc]init]; _ageTitleLb.font = LCFont(15); _ageTitleLb.textColor = HexColorFromRGBA(0x000000,0.3); _ageTitleLb.textAlignment = NSTextAlignmentLeft; _ageTitleLb.textAlignment = NSTextAlignmentLeft; _ageTitleLb.text = @"年龄"; } return _ageTitleLb; } - (UILabel *)ageContentLb{ if (!_ageContentLb) { _ageContentLb = [[UILabel alloc]init]; _ageContentLb.font = LCBoldFont(17); _ageContentLb.textColor = HexColorFromRGB(0x000000); _ageContentLb.textAlignment = NSTextAlignmentRight; _ageContentLb.text = @"18"; } return _ageContentLb; } @end