// // MSRoomMenuGameCell.m // YuMi // // Created by duoban on 2024/4/29. // #import "MSRoomMenuGameCell.h" @interface MSRoomMenuGameCell() @property(nonatomic,strong) NetImageView *gameView; @property(nonatomic,strong) UILabel *textView; @end @implementation MSRoomMenuGameCell -(instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if(self){ [self installUI]; [self installConstraints]; } return self; } -(void)installUI{ [self.contentView addSubview:self.gameView]; [self.contentView addSubview:self.textView]; } -(void)installConstraints{ [self.gameView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.leading.trailing.mas_equalTo(self.contentView).inset(4); make.height.mas_equalTo(self.gameView.mas_width); // make.centerX.equalTo(self.contentView); }]; [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.gameView.mas_bottom).mas_offset(7); make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(5)); }]; } - (void)setModel:(ActivityInfoModel *)model{ _model = model; _gameView.image = nil; @kWeakify(self); [_gameView loadImageWithUrl:_model.icon completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { @kStrongify(self); self.gameView.image = image; }]; _textView.text = _model.name; } - (void)setMoreItemModel:(XPRoomMoreItemModel *)moreItemModel { _moreItemModel = moreItemModel; _gameView.image = [UIImage getLanguageImage:moreItemModel.imageName]; } - (void)setLittleGameModel:(LittleGameInfoModel *)littleGameModel{ _littleGameModel = littleGameModel; _gameView.image = nil; @kWeakify(self); [_gameView loadImageWithUrl:littleGameModel.pic2 completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { @kStrongify(self); self.gameView.image = image; }]; _textView.text = littleGameModel.name; } #pragma mark - 懒加载 - (NetImageView *)gameView{ if(!_gameView){ NetImageConfig *config = [NetImageConfig new]; config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder]; _gameView = [[NetImageView alloc]initWithConfig:config]; _gameView.contentMode = UIViewContentModeScaleToFill; _gameView.layer.cornerRadius = kGetScaleWidth(6); _gameView.layer.masksToBounds = YES; } return _gameView; } - (UILabel *)textView{ if(!_textView){ _textView = [UILabel labelInitWithText:@"" font:kFontRegular(12) textColor:[UIColor whiteColor]]; _textView.textAlignment = NSTextAlignmentCenter; _textView.numberOfLines = 2; _textView.hidden = NO; } return _textView; } @end