猎豆优选

LDGoodDetailImageCell.m 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // LDGoodDetailImageCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/11/13.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDGoodDetailImageCell.h"
  9. @interface LDGoodDetailImageCell ()
  10. @property (nonatomic, strong) UIImageView *imgView;
  11. @end
  12. @implementation LDGoodDetailImageCell
  13. + (instancetype)cellWithTableView:(UITableView *)tableView {
  14. static NSString *cellID = nil;
  15. cellID = NSStringFromClass([self class]);
  16. LDGoodDetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  17. if (!cell) {
  18. cell = [[LDGoodDetailImageCell 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:(LDDetailImgModel *)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