// // KXEventCollectionViewCell.m // CAISHEN // // Created by jikaipeng on 2017/8/25. // Copyright © 2017年 kuxuan. All rights reserved. // #import "KXEventCollectionViewCell.h" @interface KXEventCollectionViewCell () @property (nonatomic, strong) UILabel *titlelabel; @property (nonatomic, strong) UIImageView *ImageView; @property (nonatomic, strong) UILabel *timeLabel; @property (nonatomic, strong) UILabel *detailLabel; @property (nonatomic, strong) UIImageView *backImageView; @end @implementation KXEventCollectionViewCell - (instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self addSubview:self.titlelabel]; [self addSubview:self.ImageView]; [self addSubview:self.timeLabel]; [self addSubview:self.backImageView]; [self addSubview:self.detailLabel]; [self addConstaints]; } return self; } #pragma mark - event handle - (void)addConstaints{ [self.titlelabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.mas_top).offset(16); make.left.equalTo(self.mas_left).offset(7); }]; [self.ImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.equalTo(CGSizeMake(340*SCREEN_MUTI, 150*SCREEN_MUTI)); make.left.equalTo(self.mas_left).offset(8); make.top.equalTo(self.titlelabel.mas_bottom).offset(8); }]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.ImageView.mas_left); make.top.equalTo(self.ImageView.mas_bottom).offset(8); }]; [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.timeLabel.mas_top); make.right.equalTo(self.ImageView.mas_right); make.size.equalTo(CGSizeMake(10, 13)); }]; [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.backImageView.mas_left).offset(-20); make.top.equalTo(self.backImageView.mas_top); }]; } #pragma mark - getter and setter - (void)setModel:(KXEventModel *)model{ _model = model; self.titlelabel.text = model.title; [self.ImageView sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"placeholder_rectangle"]]; self.timeLabel.text = model.start_time; self.backImageView.image = [UIImage imageNamed:@"main_event_back"]; self.detailLabel.text = @"查看详情"; } - (UILabel *)timeLabel{ if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.font = FONT_SYS(12); _timeLabel.textColor = [UIColor KXColorWithHex:0x666666]; } return _timeLabel; } - (UILabel *)titlelabel{ if (!_titlelabel) { _titlelabel = [[UILabel alloc] init]; _titlelabel.font = FONT_SYS(16); _titlelabel.textColor = [UIColor titleColor]; } return _titlelabel; } - (UILabel *)detailLabel{ if (!_detailLabel) { _detailLabel = [[UILabel alloc] init]; _detailLabel.font = FONT_SYS(12); _detailLabel.textColor = [UIColor KXColorWithHex:0x666666]; } return _detailLabel; } - (UIImageView *)ImageView{ if (!_ImageView) { _ImageView = [[UIImageView alloc] init]; } return _ImageView; } - (UIImageView *)backImageView{ if (!_backImageView) { _backImageView = [[UIImageView alloc] init]; } return _backImageView; } @end