123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // XYHotGiveRewardUserListTableViewCell.m
- // Timi
- //
- // Created by 翟玉磊 on 2021/11/16.
- //
- #import "XYHotGiveRewardUserListTableViewCell.h"
- #import "XYHotGiveRewardUserListModel.h"
- @interface XYHotGiveRewardUserListTableViewCell ()
- @property (nonatomic, strong) UIImageView *headImageView;
- @property (nonatomic, strong) UILabel *userNameLabel;
- @property (nonatomic, strong) UILabel *giftTitleLabel;
- @property (nonatomic, strong) UILabel *giftNameLabel;
- @property (nonatomic, strong) UIImageView *giftImageView;
- @end
- @implementation XYHotGiveRewardUserListTableViewCell
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- XYHotGiveRewardUserListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:XYHotGiveRewardUserListTableViewCell.className];
- if (cell == nil) {
- cell = [[XYHotGiveRewardUserListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:XYHotGiveRewardUserListTableViewCell.className];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)configureModel:(XYHotGiveRewardUserListModel *)model {
- [self.headImageView sd_setImageWithURL:UrlForString(model.userAvatar) placeholderImage:placeholderUserIcon()];
- self.userNameLabel.text = model.userName;
-
- self.giftTitleLabel.text = @"打赏";
- self.giftNameLabel.text = model.giftName;
- [self.giftImageView sd_setImageWithURL:UrlForString(model.giftIcon) placeholderImage:placeholderImage()];
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI {
- [self.contentView addSubview:self.headImageView];
- [self.contentView addSubview:self.userNameLabel];
- [self.contentView addSubview:self.giftImageView];
- [self.contentView addSubview:self.giftNameLabel];
- [self.contentView addSubview:self.giftTitleLabel];
-
- [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(16.0f);
- make.width.height.equalTo(@32.0f);
- make.centerY.equalTo(self.contentView);
- }];
- [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headImageView.mas_right).offset(8.0f);
- make.centerY.equalTo(self.contentView);
- make.height.equalTo(@20.0f);
- }];
- [self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-16.0f);
- make.centerY.equalTo(self.contentView);
- make.width.height.equalTo(@32.0f);
- }];
- [self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.giftImageView.mas_left).offset(-4.0f);
- make.centerY.equalTo(self.contentView);
- make.height.equalTo(@17.0f);
- }];
- [self.giftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.giftNameLabel.mas_left).offset(-4.0f);
- make.centerY.equalTo(self.contentView);
- make.height.equalTo(@17.0f);
- make.left.greaterThanOrEqualTo(self.userNameLabel.mas_right).offset(10.0f);
- }];
-
- [self.headImageView addViewBorder:Color_Clear redian:32/2];
-
- }
- #pragma mark - lazy
- - (UIImageView *)headImageView {
- if (_headImageView == nil) {
- _headImageView = [UIImageView new];
- _headImageView.clipsToBounds = YES;
- _headImageView.contentMode = UIViewContentModeScaleAspectFill;
- }
- return _headImageView;
- }
- - (UILabel *)userNameLabel {
- if (_userNameLabel == nil) {
- _userNameLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(14)];
- }
- return _userNameLabel;
- }
- - (UILabel *)giftTitleLabel {
- if (_giftTitleLabel == nil) {
- _giftTitleLabel = [UILabel createLabelTextColor:Color_TextGray fount:Font(12)];
- _giftTitleLabel.textAlignment = NSTextAlignmentRight;
- _giftTitleLabel.text = @"打赏";
- }
- return _giftTitleLabel;
- }
- - (UILabel *)giftNameLabel {
- if (_giftNameLabel == nil) {
- _giftNameLabel = [UILabel createLabelTextColor:Color_TextRed fount:Font(12)];
- _giftNameLabel.textAlignment = NSTextAlignmentRight;
- }
- return _giftNameLabel;
- }
- - (UIImageView *)giftImageView {
- if (_giftImageView == nil) {
- _giftImageView = [UIImageView new];
- _giftImageView.clipsToBounds = YES;
- _giftImageView.contentMode = UIViewContentModeScaleAspectFill;
- }
- return _giftImageView;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|