// // KBGoodDetailImageCell.m // YouHuiProject // // Created by 小花 on 2018/10/11. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBGoodDetailImageCell.h" @interface KBGoodDetailImageCell () @property (nonatomic, strong) UIImageView *imgView; @end @implementation KBGoodDetailImageCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); KBGoodDetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[KBGoodDetailImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.backgroundColor=[UIColor yhGrayColor]; } return cell; } - (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 } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initSubViews]; } return self; } - (void)initSubViews { [self.contentView addSubview:self.imgView]; [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.bottom.mas_equalTo(0); }]; } - (void)setModel:(KBDetailImgModel *)model { [self.imgView sd_setFadeImageWithURL:[NSURL URLWithString:model.url] placeholderImage:nil options:0 progress:nil completed:nil]; } - (UIImageView *)imgView { if (!_imgView) { _imgView = [[UIImageView alloc] init]; _imgView.contentMode = UIViewContentModeScaleAspectFit; } return _imgView; } @end