// // YMPersonalPageAlbumCell.m // MSYOUPAI // // Created by YoMi on 2024/2/17. // Copyright © 2024 MS. All rights reserved. // #import "YMPersonalPageMainAlbumCell.h" #import "YMPersonalPageAlbumCellViewModel.h" @interface YMPersonalPageMainAlbumCell() /// ViewModel @property (nonatomic, strong) YMPersonalPageAlbumCellViewModel *viewModel; /// 基础视图 @property (nonatomic, strong) UIView *baseView; /// 相册图片视图 @property (nonatomic, strong) UIImageView *albumImageView; @end @implementation YMPersonalPageMainAlbumCell - (void)ym_setupViews{ [self.contentView addSubview:self.baseView]; [self.baseView addSubview:self.albumImageView]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; } - (void)updateConstraints { [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView); }]; [self.albumImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.baseView); make.left.equalTo(self.baseView); make.right.equalTo(self.baseView); make.bottom.equalTo(self.baseView); }]; [super updateConstraints]; } - (void)ym_bindViewModel:(YMPersonalPageAlbumCellViewModel*)viewModel{ if (!viewModel) { return; } _viewModel = viewModel; [self.albumImageView sd_setImageWithURL:[LCTools getImageUrlWithAddress:viewModel.albumUrl]]; } - (UIView *)baseView{ if (!_baseView) { _baseView = [[UIView alloc]init]; } return _baseView; } - (UIImageView *)albumImageView{ if (!_albumImageView) { _albumImageView = [[UIImageView alloc]init]; _albumImageView.backgroundColor = UIColor.lightGrayColor; _albumImageView.contentMode = UIViewContentModeScaleAspectFill; _albumImageView.clipsToBounds = YES; } return _albumImageView; } @end