YMPersonalPageMainAlbumCell.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // YMPersonalPageAlbumCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/17.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPersonalPageMainAlbumCell.h"
  9. #import "YMPersonalPageAlbumCellViewModel.h"
  10. @interface YMPersonalPageMainAlbumCell()
  11. /// ViewModel
  12. @property (nonatomic, strong) YMPersonalPageAlbumCellViewModel *viewModel;
  13. /// 基础视图
  14. @property (nonatomic, strong) UIView *baseView;
  15. /// 相册图片视图
  16. @property (nonatomic, strong) UIImageView *albumImageView;
  17. @end
  18. @implementation YMPersonalPageMainAlbumCell
  19. - (void)ym_setupViews{
  20. [self.contentView addSubview:self.baseView];
  21. [self.baseView addSubview:self.albumImageView];
  22. [self setNeedsUpdateConstraints];
  23. [self updateConstraintsIfNeeded];
  24. }
  25. - (void)updateConstraints {
  26. [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.top.equalTo(self.contentView);
  28. make.left.equalTo(self.contentView);
  29. make.right.equalTo(self.contentView);
  30. make.bottom.equalTo(self.contentView);
  31. }];
  32. [self.albumImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.equalTo(self.baseView);
  34. make.left.equalTo(self.baseView);
  35. make.right.equalTo(self.baseView);
  36. make.bottom.equalTo(self.baseView);
  37. }];
  38. [super updateConstraints];
  39. }
  40. - (void)ym_bindViewModel:(YMPersonalPageAlbumCellViewModel*)viewModel{
  41. if (!viewModel) {
  42. return;
  43. }
  44. _viewModel = viewModel;
  45. [self.albumImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:viewModel.albumUrl]];
  46. }
  47. - (UIView *)baseView{
  48. if (!_baseView) {
  49. _baseView = [[UIView alloc]init];
  50. }
  51. return _baseView;
  52. }
  53. - (UIImageView *)albumImageView{
  54. if (!_albumImageView) {
  55. _albumImageView = [[UIImageView alloc]init];
  56. _albumImageView.backgroundColor = UIColor.lightGrayColor;
  57. _albumImageView.contentMode = UIViewContentModeScaleAspectFill;
  58. _albumImageView.clipsToBounds = YES;
  59. }
  60. return _albumImageView;
  61. }
  62. @end