123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // 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
|