猎豆优选

LDTodayModelCollectionCell.m 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // LDTodayModelCollectionCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/11.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDTodayModelCollectionCell.h"
  9. @interface LDTodayModelCollectionCell ()
  10. @property (nonatomic, strong) UIImageView *iconView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @end
  13. @implementation LDTodayModelCollectionCell
  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(Fitsize(5), 0, SCREEN_WIDTH-Fitsize(10), Fitsize(218))];
  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(11), 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 = [[LDTodayModelView alloc] initWithFrame:CGRectMake(Fitsize(8), Fitsize(50), SCREEN_WIDTH-Fitsize(26), bgView.height-Fitsize(50))];
  47. [bgView addSubview:self.modelView];
  48. }
  49. - (void)setModel:(LDTodayMudleModel *)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