// // KBPotentialFansCell.m // YouHuiProject // // Created by 小花 on 2018/7/12. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBPotentialFansCell.h" @interface KBPotentialFansCell () @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) UILabel *name; @property (nonatomic, strong) UILabel *date; @end @implementation KBPotentialFansCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); KBPotentialFansCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[KBPotentialFansCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } return cell; } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initUI]; } return self; } - (void)initUI { [self.contentView addSubview:self.iconView]; [self.contentView addSubview:self.name]; [self.contentView addSubview:self.date]; [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.width.height.mas_equalTo(50); make.centerY.mas_equalTo(self.mas_centerY); }]; [self.name mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.iconView.mas_right).mas_offset(15); make.top.mas_equalTo(15); }]; [self.date mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.name.mas_left); make.top.mas_equalTo(self.name.mas_bottom).mas_offset(6); }]; } - (void)setModel:(KBPotentialModel *)model { _model = model; self.name.text = model.name; self.date.text = model.create_at; [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"login"]]; } #pragma mark -懒加载 - (UIImageView *)iconView { if (!_iconView) { _iconView = [[UIImageView alloc] init]; _iconView.contentMode = UIViewContentModeScaleAspectFill; _iconView.layer.masksToBounds = YES; _iconView.backgroundColor = [UIColor yhGrayColor]; [_iconView setImage:[UIImage imageNamed:@"login"]]; _iconView.layer.cornerRadius = 25; } return _iconView; } - (UILabel *)name { if (!_name) { _name = [[UILabel alloc] init]; _name.textColor = [UIColor YHColorWithHex:0x333333]; _name.font = [UIFont systemFontOfSize:14]; _name.text = @"未知用户"; } return _name; } - (UILabel *)date { if (!_date) { _date = [[UILabel alloc] init]; _date.textColor = [UIColor YHColorWithHex:0x878787]; _date.font = [UIFont systemFontOfSize:12]; _date.text = @"--"; } return _date; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end