// // KXTeachCollectionViewCell.m // CAISHEN // // Created by kuxuan on 2017/11/1. // Copyright © 2017年 kuxuan. All rights reserved. // #import "KXTeachCollectionViewCell.h" @implementation KXTeachCollectionViewCell { UIImageView *_thumbImageView; UILabel *_titleLabel; } - (instancetype)initWithFrame:(CGRect)frame { if (self == [super initWithFrame:frame]) { [self setupUI]; } return self; } - (void)setupUI { _thumbImageView = [[UIImageView alloc]init]; [self.contentView addSubview:_thumbImageView]; _titleLabel = [[UILabel alloc]init]; _titleLabel.textAlignment = NSTextAlignmentCenter; _titleLabel.font = FONT_SYS(12); _titleLabel.textColor = [UIColor titleColor]; [self.contentView addSubview:_titleLabel]; [_thumbImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.equalTo(self.contentView); make.height.mas_equalTo(80); }]; [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_thumbImageView.mas_bottom); make.left.right.bottom.equalTo(self.contentView); }]; } - (void)setNewsModel:(KXNewsModel *)newsModel { _newsModel = newsModel; [_thumbImageView sd_setImageWithURL:[NSURL URLWithString:newsModel.thumbnail] placeholderImage:[UIImage imageNamed:@"placeholder_square"] options:0]; _titleLabel.text = newsModel.sub_title; } @end