口袋优选

KBGoodDetailImageCell.m 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // KBGoodDetailImageCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/10/11.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBGoodDetailImageCell.h"
  9. @interface KBGoodDetailImageCell ()
  10. @property (nonatomic, strong) UIImageView *imgView;
  11. @end
  12. @implementation KBGoodDetailImageCell
  13. + (instancetype)cellWithTableView:(UITableView *)tableView {
  14. static NSString *cellID = nil;
  15. cellID = NSStringFromClass([self class]);
  16. KBGoodDetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  17. if (!cell) {
  18. cell = [[KBGoodDetailImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  19. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  20. cell.backgroundColor=[UIColor yhGrayColor];
  21. }
  22. return cell;
  23. }
  24. - (void)awakeFromNib {
  25. [super awakeFromNib];
  26. // Initialization code
  27. }
  28. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  29. [super setSelected:selected animated:animated];
  30. // Configure the view for the selected state
  31. }
  32. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  33. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  34. if (self) {
  35. [self initSubViews];
  36. }
  37. return self;
  38. }
  39. - (void)initSubViews {
  40. [self.contentView addSubview:self.imgView];
  41. [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.left.right.top.bottom.mas_equalTo(0);
  43. }];
  44. }
  45. - (void)setModel:(KBDetailImgModel *)model {
  46. [self.imgView sd_setFadeImageWithURL:[NSURL URLWithString:model.url] placeholderImage:nil options:0 progress:nil completed:nil];
  47. }
  48. - (UIImageView *)imgView {
  49. if (!_imgView) {
  50. _imgView = [[UIImageView alloc] init];
  51. _imgView.contentMode = UIViewContentModeScaleAspectFit;
  52. }
  53. return _imgView;
  54. }
  55. @end