123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //
- // 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(22));
- }];
-
- [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.ageTitleLb.mas_bottom).offset(adapt(5));
- make.left.equalTo(self);
- make.right.equalTo(self);
- make.height.mas_equalTo(adapt(48));
- }];
-
- [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 = HexColorFromRGBA(0xF2F5FF,1);
- _baseView.layer.borderColor = HexColorFromRGBA(0xF2F5FF,1).CGColor;
- _baseView.layer.borderWidth = 1;
- _baseView.layer.cornerRadius = adapt(24);
- _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(13);
- _ageTitleLb.textColor = HexColorFromRGBA(0x333333,1);
- _ageTitleLb.textAlignment = NSTextAlignmentLeft;
- _ageTitleLb.text = @"年龄";
- }
- return _ageTitleLb;
- }
- - (UILabel *)ageContentLb{
- if (!_ageContentLb) {
- _ageContentLb = [[UILabel alloc]init];
- _ageContentLb.font = LCFont(13);
- _ageContentLb.textColor = HexColorFromRGB(0x333333);
- _ageContentLb.textAlignment = NSTextAlignmentLeft;
- _ageContentLb.text = @"18";
- }
- return _ageContentLb;
- }
- @end
|