// // DRGoodDetailImageCell.m // YouHuiProject // // Created by 小花 on 2018/11/13. // Copyright © 2018年 kuxuan. All rights reserved. // #import "DRGoodDetailImageCell.h" @interface DRGoodDetailImageCell () @property (nonatomic, strong) UIImageView *imgView; @end @implementation DRGoodDetailImageCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); DRGoodDetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[DRGoodDetailImageCell 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:(DRDetailImgModel *)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