1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // LDTodayModelCollectionCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/11.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDTodayModelCollectionCell.h"
- @interface LDTodayModelCollectionCell ()
- @property (nonatomic, strong) UIImageView *iconView;
- @property (nonatomic, strong) UILabel *titleLabel;
- @end
- @implementation LDTodayModelCollectionCell
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
-
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(Fitsize(5), 0, SCREEN_WIDTH-Fitsize(10), Fitsize(218))];
- 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(11), 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 = [[LDTodayModelView alloc] initWithFrame:CGRectMake(Fitsize(8), Fitsize(50), SCREEN_WIDTH-Fitsize(26), bgView.height-Fitsize(50))];
- [bgView addSubview:self.modelView];
-
-
- }
- - (void)setModel:(LDTodayMudleModel *)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
|