YMEditProfileInfoCell.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // YMEditProfileInfoCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/18.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMEditProfileInfoCell.h"
  9. #import "YMEditProfileInfoCellViewModel.h"
  10. @interface YMEditProfileInfoCell ()
  11. /// 信息VM
  12. @property (nonatomic, strong) YMEditProfileInfoCellViewModel *viewModel;
  13. /// 基础视图
  14. @property (nonatomic, strong) UIView *baseView;
  15. /// 信息标题标签
  16. @property (nonatomic, strong) UILabel *infoTitleLb;
  17. /// 信息内容标签
  18. @property (nonatomic, strong) UILabel *infoContentLb;
  19. /// 箭头图标
  20. @property (nonatomic, strong) UIImageView *arrowIcon;
  21. @end
  22. @implementation YMEditProfileInfoCell
  23. - (void)awakeFromNib {
  24. [super awakeFromNib];
  25. // Initialization code
  26. }
  27. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  28. [super setSelected:selected animated:animated];
  29. // Configure the view for the selected state
  30. }
  31. - (void)ym_setupViews{
  32. [self.contentView addSubview:self.baseView];
  33. [self.baseView addSubview:self.infoTitleLb];
  34. [self.baseView addSubview:self.infoContentLb];
  35. [self.baseView addSubview:self.arrowIcon];
  36. [self setNeedsUpdateConstraints];
  37. [self updateConstraintsIfNeeded];
  38. }
  39. - (void)updateConstraints{
  40. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.equalTo(self.contentView);
  42. make.left.equalTo(self.contentView);
  43. make.right.equalTo(self.contentView);
  44. make.bottom.equalTo(self.contentView);
  45. }];
  46. [self.infoTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.centerY.equalTo(self.baseView.mas_centerY);
  48. make.left.equalTo(self.baseView).offset(adapt(15));
  49. }];
  50. [self.infoContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.centerY.equalTo(self.infoTitleLb.mas_centerY);
  52. make.right.equalTo(self.arrowIcon.mas_left).offset(adapt(-10));
  53. }];
  54. [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.centerY.equalTo(self.infoTitleLb.mas_centerY);
  56. make.right.equalTo(self).offset(adapt(-15));
  57. make.width.mas_equalTo(adapt(10));
  58. make.height.mas_equalTo(adapt(9));
  59. }];
  60. [super updateConstraints];
  61. }
  62. - (void)ym_bindViewModel:(YMEditProfileInfoCellViewModel *)viewModel{
  63. if (!viewModel) {
  64. return;
  65. }
  66. _viewModel = viewModel;
  67. self.infoTitleLb.text = self.viewModel.infoTitle;
  68. self.infoContentLb.text = self.viewModel.infoContent;
  69. self.infoContentLb.textColor = self.viewModel.infoContentColor;
  70. }
  71. - (UIView *)baseView{
  72. if (!_baseView) {
  73. _baseView = [[UIView alloc]init];
  74. }
  75. return _baseView;
  76. }
  77. - (UILabel *)infoTitleLb{
  78. if (!_infoTitleLb) {
  79. _infoTitleLb = [[UILabel alloc]init];
  80. _infoTitleLb.font = LCBoldFont(16);
  81. _infoTitleLb.textColor = HexColorFromRGB(0x333333);
  82. _infoTitleLb.textAlignment = NSTextAlignmentLeft;
  83. _infoTitleLb.text = @"信息";
  84. }
  85. return _infoTitleLb;
  86. }
  87. - (UILabel *)infoContentLb{
  88. if (!_infoContentLb) {
  89. _infoContentLb = [[UILabel alloc]init];
  90. _infoContentLb.font = LCFont(13);
  91. _infoContentLb.textColor = HexColorFromRGB(0x9c9c9c);
  92. _infoContentLb.textAlignment = NSTextAlignmentRight;
  93. _infoContentLb.text = @"去完善";
  94. }
  95. return _infoContentLb;
  96. }
  97. - (UIImageView *)arrowIcon{
  98. if (!_arrowIcon) {
  99. _arrowIcon = [[UIImageView alloc]init];
  100. _arrowIcon.image = ImageByName(@"ym_edit_profile_arrow_icon");
  101. }
  102. return _arrowIcon;
  103. }
  104. @end