YMAboutUsCell.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // YMAboutUsCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/21.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAboutUsCell.h"
  9. #import "YMAboutUsCellViewModel.h"
  10. @interface YMAboutUsCell ()
  11. /// 关于我们VM
  12. @property (nonatomic, strong) YMAboutUsCellViewModel *viewModel;
  13. /// 基础视图
  14. @property (nonatomic, strong) UIView *baseView;
  15. /// 关于我们标题标签
  16. @property (nonatomic, strong) UILabel *aboutUsTitleLb;
  17. /// 箭头图标
  18. @property (nonatomic, strong) UIImageView *arrowIcon;
  19. @end
  20. @implementation YMAboutUsCell
  21. - (void)awakeFromNib {
  22. [super awakeFromNib];
  23. // Initialization code
  24. }
  25. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  26. [super setSelected:selected animated:animated];
  27. // Configure the view for the selected state
  28. }
  29. - (void)ym_setupViews{
  30. [self.contentView addSubview:self.baseView];
  31. [self.baseView addSubview:self.aboutUsTitleLb];
  32. [self.baseView addSubview:self.arrowIcon];
  33. [self setNeedsUpdateConstraints];
  34. [self updateConstraintsIfNeeded];
  35. }
  36. - (void)updateConstraints{
  37. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(self.contentView);
  39. make.left.equalTo(self.contentView);
  40. make.right.equalTo(self.contentView);
  41. make.bottom.equalTo(self.contentView);
  42. }];
  43. [self.aboutUsTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.centerY.equalTo(self.baseView.mas_centerY);
  45. make.left.equalTo(self.baseView).offset(adapt(15));
  46. }];
  47. [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.centerY.equalTo(self.aboutUsTitleLb.mas_centerY);
  49. make.right.equalTo(self).offset(adapt(-15));
  50. make.width.mas_equalTo(adapt(10));
  51. make.height.mas_equalTo(adapt(9));
  52. }];
  53. [super updateConstraints];
  54. }
  55. - (void)ym_bindViewModel:(YMAboutUsCellViewModel *)viewModel{
  56. if (!viewModel) {
  57. return;
  58. }
  59. _viewModel = viewModel;
  60. self.aboutUsTitleLb.text = self.viewModel.aboutUsTitle;
  61. }
  62. - (UIView *)baseView{
  63. if (!_baseView) {
  64. _baseView = [[UIView alloc]init];
  65. }
  66. return _baseView;
  67. }
  68. - (UILabel *)aboutUsTitleLb{
  69. if (!_aboutUsTitleLb) {
  70. _aboutUsTitleLb = [[UILabel alloc]init];
  71. _aboutUsTitleLb.font = LCFont(15);
  72. _aboutUsTitleLb.textColor = HexColorFromRGB(0x333333);
  73. _aboutUsTitleLb.textAlignment = NSTextAlignmentLeft;
  74. _aboutUsTitleLb.text = @"功能";
  75. }
  76. return _aboutUsTitleLb;
  77. }
  78. - (UIImageView *)arrowIcon{
  79. if (!_arrowIcon) {
  80. _arrowIcon = [[UIImageView alloc]init];
  81. _arrowIcon.image = ImageByName(@"ym_edit_profile_arrow_icon");
  82. }
  83. return _arrowIcon;
  84. }
  85. @end