dkahgld

ZBProductClassListCell.m 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // ZBProductClassListCell.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/15.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBProductClassListCell.h"
  9. @implementation ZBProductClassListCell
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. [self addSubview:self.imageView];
  15. [self addSubview:self.label];
  16. [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.centerX.mas_equalTo(self.mas_centerX);
  18. make.top.mas_equalTo(13);
  19. make.width.height.mas_equalTo(48);
  20. }];
  21. [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
  22. make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(3);
  23. make.left.right.mas_equalTo(0);
  24. make.height.mas_equalTo(15);
  25. }];
  26. }
  27. return self;
  28. }
  29. -(void)setModel:(ClassModel *)model
  30. {
  31. _model = model;
  32. [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.icon]];
  33. self.label.text=model.name;
  34. }
  35. - (UIImageView *)imageView {
  36. if (!_imageView) {
  37. _imageView = [[UIImageView alloc] init];
  38. _imageView.layer.cornerRadius = Fitsize(4);
  39. _imageView.layer.masksToBounds = YES;
  40. _imageView.image = [UIImage imageNamed:@"category"];
  41. }
  42. return _imageView;
  43. }
  44. - (UILabel *)label {
  45. if (!_label) {
  46. _label = [[UILabel alloc] init];
  47. _label.textAlignment = NSTextAlignmentCenter;
  48. _label.font = [UIFont systemFontOfSize:12];
  49. _label.textColor = [UIColor YHColorWithHex:0x444444];
  50. _label.text = @"人气榜单";
  51. }
  52. return _label;
  53. }
  54. @end