YMImproveInfoAgeView.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // YMImproveInfoAgeView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/8.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMImproveInfoAgeView.h"
  9. #import "YMImproveInfoViewModel.h"
  10. @interface YMImproveInfoAgeView ()
  11. /// 完善信息VM
  12. @property (nonatomic, strong) YMImproveInfoViewModel *viewModel;
  13. /// 年龄标题标签
  14. @property (nonatomic, strong) UILabel *ageTitleLb;
  15. /// 年龄内容标签
  16. @property (nonatomic, strong) UILabel *ageContentLb;
  17. @property (nonatomic, strong) UIView *baseView;
  18. @property (nonatomic, strong) UIImageView *rightImgV;
  19. @end
  20. @implementation YMImproveInfoAgeView
  21. - (void)ym_setupViews{
  22. [self addSubview:self.ageTitleLb];
  23. [self addSubview:self.baseView];
  24. [self.baseView addSubview:self.ageContentLb];
  25. [self.baseView addSubview:self.rightImgV];
  26. [self setNeedsUpdateConstraints];
  27. [self updateConstraintsIfNeeded];
  28. }
  29. - (void)updateConstraints{
  30. [self.ageTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.equalTo(self);
  32. make.left.equalTo(self);
  33. make.height.mas_equalTo(adapt(22));
  34. }];
  35. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.equalTo(self.ageTitleLb.mas_bottom).offset(adapt(5));
  37. make.left.equalTo(self);
  38. make.right.equalTo(self);
  39. make.height.mas_equalTo(adapt(48));
  40. }];
  41. [self.ageContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.centerY.equalTo(self.baseView);
  43. make.left.equalTo(self.baseView).offset(adapt(16));
  44. }];
  45. [self.rightImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerY.equalTo(self.baseView);
  47. make.right.equalTo(self.baseView).offset(adapt(-16));
  48. make.width.mas_equalTo(adapt(16));
  49. make.height.mas_equalTo(adapt(16));
  50. }];
  51. [super updateConstraints];
  52. }
  53. - (void)ym_bindViewModel:(YMImproveInfoViewModel *)viewModel{
  54. if (!viewModel) {
  55. return;
  56. }
  57. _viewModel = viewModel;
  58. RAC(self.ageContentLb, text) = RACObserve(self.viewModel, improveInfoAge);
  59. }
  60. - (UIView *)baseView{
  61. if (!_baseView) {
  62. _baseView = [[UIView alloc]init];
  63. _baseView.backgroundColor = HexColorFromRGBA(0xF2F5FF,1);
  64. _baseView.layer.borderColor = HexColorFromRGBA(0xF2F5FF,1).CGColor;
  65. _baseView.layer.borderWidth = 1;
  66. _baseView.layer.cornerRadius = adapt(24);
  67. _baseView.layer.masksToBounds = true;
  68. }
  69. return _baseView;
  70. }
  71. - (UIImageView *)rightImgV{
  72. if (!_rightImgV) {
  73. _rightImgV = [[UIImageView alloc]init];
  74. _rightImgV.userInteractionEnabled = true;
  75. _rightImgV.image = ImageByName(@"ym_improve_info_right_icon");
  76. }
  77. return _rightImgV;
  78. }
  79. - (UILabel *)ageTitleLb{
  80. if (!_ageTitleLb) {
  81. _ageTitleLb = [[UILabel alloc]init];
  82. _ageTitleLb.font = LCFont(13);
  83. _ageTitleLb.textColor = HexColorFromRGBA(0x333333,1);
  84. _ageTitleLb.textAlignment = NSTextAlignmentLeft;
  85. _ageTitleLb.text = @"年龄";
  86. }
  87. return _ageTitleLb;
  88. }
  89. - (UILabel *)ageContentLb{
  90. if (!_ageContentLb) {
  91. _ageContentLb = [[UILabel alloc]init];
  92. _ageContentLb.font = LCFont(13);
  93. _ageContentLb.textColor = HexColorFromRGB(0x333333);
  94. _ageContentLb.textAlignment = NSTextAlignmentLeft;
  95. _ageContentLb.text = @"18";
  96. }
  97. return _ageContentLb;
  98. }
  99. @end