123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // KBTodayModelCollectionCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/11.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBTodayModelCollectionCell.h"
- @interface KBTodayModelCollectionCell ()
- @property (nonatomic, strong) UIImageView *iconView;
- @property (nonatomic, strong) UILabel *titleLabel;
- @end
- @implementation KBTodayModelCollectionCell
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
-
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-Fitsize(20), Fitsize(228))];
- bgView.backgroundColor = [UIColor whiteColor];
- bgView.layer.cornerRadius = 10;
- [self.contentView addSubview:bgView];
-
-
- UIView *topBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, Fitsize(50))];
- [bgView addSubview:topBg];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreBtnClick)];
- [topBg addGestureRecognizer:tap];
-
- UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(Fitsize(6), Fitsize(7), Fitsize(120), Fitsize(25))];
- imgView.contentMode = UIViewContentModeScaleAspectFit;
- imgView.centerY = Fitsize(25);
- self.iconView = imgView;
- [topBg addSubview:imgView];
-
- self.desLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgView.right+10, 0, Fitsize(200), Fitsize(30))];
- self.desLabel.centerY = Fitsize(25);
- self.desLabel.textColor = [UIColor YHColorWithHex:0x999999];
- self.desLabel.font = [UIFont systemFontOfSize:Fitsize(13)];
-
- [topBg addSubview:self.desLabel];
-
- UIButton *moreBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 45, 30)];
- moreBtn.centerY = Fitsize(25);
- moreBtn.right = bgView.width-5;
- [moreBtn addTarget:self action:@selector(moreBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [moreBtn setImage:[UIImage imageNamed:@"goto"] forState:UIControlStateNormal];
- [topBg addSubview:moreBtn];
-
- self.modelView = [[KBTodayModelView alloc] initWithFrame:CGRectMake(Fitsize(3), Fitsize(50), SCREEN_WIDTH-Fitsize(26), bgView.height-Fitsize(50))];
- [bgView addSubview:self.modelView];
-
-
- }
- - (void)setModel:(KBTodayMudleModel *)model {
- _model = model;
- [self.modelView setGoodData:model.dataList];
- [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
- if (image) {
- CGFloat scale = self.iconView.height/image.size.height;
- self.iconView.width = scale * image.size.width;
- }
- }];
- self.modelView.Id = model.Id;
- self.desLabel.text = model.group_desc;
- self.modelView.name = model.name;
- }
- - (void)moreBtnClick {
- if (self.delegate && [self.delegate respondsToSelector:@selector(modelCollectionCellMoreButtonClick:)]) {
- [self.delegate modelCollectionCellMoreButtonClick:self];
- }
- }
- @end
|