// // KBMessageListCell.m // YouHuiProject // // Created by 小花 on 2018/5/21. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBMessageListCell.h" @interface KBMessageListCell () @property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UILabel *dateLabel; @property (nonatomic, strong) UILabel *title; @property (nonatomic, strong) UILabel *desLabel; @property (nonatomic, strong) UIImageView *arrowIcon; @end @implementation KBMessageListCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); KBMessageListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[KBMessageListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } return cell; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor YHColorWithHex:0xf4f4f4]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self initSubViews]; } return self; } - (void)initSubViews { [self.contentView addSubview:self.dateLabel]; [self.contentView addSubview:self.bgView]; [self.bgView addSubview:self.title]; [self.bgView addSubview:self.desLabel]; [self.bgView addSubview:self.arrowIcon]; [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(14); }]; [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.top.mas_equalTo(39); make.bottom.mas_equalTo(0); }]; [self.title mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(15); make.left.mas_equalTo(15); make.height.mas_equalTo(24); }]; [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(24); make.right.mas_equalTo(-18); make.centerY.mas_equalTo(self.title); }]; [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.title); make.right.mas_equalTo(-15); make.top.mas_equalTo(self.title.mas_bottom).mas_offset(5); }]; } - (void)setModel:(KBMessageModel *)model { _model = model; self.title.text = model.title; self.desLabel.text = model.message; self.title.textColor = [model.is_view isEqualToString:@"1"] ? [UIColor YHColorWithHex:0x999999] : [UIColor YHColorWithHex:0x333333]; self.desLabel.textColor = [model.is_view isEqualToString:@"1"] ? [UIColor YHColorWithHex:0x999999] : [UIColor YHColorWithHex:0x333333]; self.dateLabel.text = model.push_at; } - (void)isRead { self.title.textColor = [UIColor YHColorWithHex:0x999999]; self.desLabel.textColor = [UIColor YHColorWithHex:0x999999]; } #pragma mark ----- - (UIView *)bgView { if (!_bgView) { _bgView = [[UIView alloc] init]; _bgView.backgroundColor = [UIColor whiteColor]; _bgView.layer.cornerRadius = 6; } return _bgView; } - (UILabel *)dateLabel { if (!_dateLabel) { _dateLabel = [[UILabel alloc] init]; _dateLabel.textColor = [UIColor YHColorWithHex:0x999999]; _dateLabel.font = [UIFont systemFontOfSize:12]; } return _dateLabel; } - (UILabel *)title { if (!_title) { _title = [[UILabel alloc] init]; _title.font = [UIFont systemFontOfSize:16]; _title.textColor = [UIColor YHColorWithHex:0x333333]; _title.text = @"热门爆款"; } return _title; } - (UILabel *)desLabel { if (!_desLabel) { _desLabel = [[UILabel alloc] init]; _desLabel.font = [UIFont systemFontOfSize:14]; _desLabel.textColor = [UIColor YHColorWithHex:0x666666]; _desLabel.text = @"福建阿附近阿克苏金卡价撒蛟龙卡聚隆科技"; } return _desLabel; } - (UIImageView *)arrowIcon { if (!_arrowIcon) { _arrowIcon = [[UIImageView alloc] init]; _arrowIcon.image = [UIImage imageNamed:@"more_acc"]; } return _arrowIcon; } @end