口袋优选

KBTodayModelCollectionCell.m 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // KBTodayModelCollectionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/11.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBTodayModelCollectionCell.h"
  9. @interface KBTodayModelCollectionCell ()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @end
  13. @implementation KBTodayModelCollectionCell
  14. - (instancetype)initWithFrame:(CGRect)frame {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. [self initSubViews];
  18. }
  19. return self;
  20. }
  21. - (void)initSubViews {
  22. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-Fitsize(20), Fitsize(228))];
  23. bgView.backgroundColor = [UIColor whiteColor];
  24. bgView.layer.cornerRadius = 10;
  25. [self.contentView addSubview:bgView];
  26. UIView *topBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, Fitsize(50))];
  27. [bgView addSubview:topBg];
  28. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreBtnClick)];
  29. [topBg addGestureRecognizer:tap];
  30. UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(Fitsize(6), Fitsize(7), Fitsize(120), Fitsize(25))];
  31. imgView.contentMode = UIViewContentModeScaleAspectFit;
  32. imgView.centerY = Fitsize(25);
  33. self.iconView = imgView;
  34. [topBg addSubview:imgView];
  35. self.desLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgView.right+10, 0, Fitsize(200), Fitsize(30))];
  36. self.desLabel.centerY = Fitsize(25);
  37. self.desLabel.textColor = [UIColor YHColorWithHex:0x999999];
  38. self.desLabel.font = [UIFont systemFontOfSize:Fitsize(13)];
  39. [topBg addSubview:self.desLabel];
  40. UIButton *moreBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 45, 30)];
  41. moreBtn.centerY = Fitsize(25);
  42. moreBtn.right = bgView.width-5;
  43. [moreBtn addTarget:self action:@selector(moreBtnClick) forControlEvents:UIControlEventTouchUpInside];
  44. [moreBtn setImage:[UIImage imageNamed:@"goto"] forState:UIControlStateNormal];
  45. [topBg addSubview:moreBtn];
  46. self.modelView = [[KBTodayModelView alloc] initWithFrame:CGRectMake(Fitsize(3), Fitsize(50), SCREEN_WIDTH-Fitsize(26), bgView.height-Fitsize(50))];
  47. [bgView addSubview:self.modelView];
  48. }
  49. - (void)setModel:(KBTodayMudleModel *)model {
  50. _model = model;
  51. [self.modelView setGoodData:model.dataList];
  52. [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  53. if (image) {
  54. CGFloat scale = self.iconView.height/image.size.height;
  55. self.iconView.width = scale * image.size.width;
  56. }
  57. }];
  58. self.modelView.Id = model.Id;
  59. self.desLabel.text = model.group_desc;
  60. self.modelView.name = model.name;
  61. }
  62. - (void)moreBtnClick {
  63. if (self.delegate && [self.delegate respondsToSelector:@selector(modelCollectionCellMoreButtonClick:)]) {
  64. [self.delegate modelCollectionCellMoreButtonClick:self];
  65. }
  66. }
  67. @end