CNNewsoundBaseTableViewCell.m
3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// CNNewsoundBaseTableViewCell.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/20.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "CNNewsoundBaseTableViewCell.h"
#import "CNNewsoundBaseModel.h"
@interface CNNewsoundBaseTableViewCell()
@property (nonatomic, strong) UIImageView *backgroundImage;//背景图
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@end
@implementation CNNewsoundBaseTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.contentView.backgroundColor = HEXCOLOR(0xebebeb);
_backgroundImage = [[UIImageView alloc] init];
_backgroundImage.contentMode = UIViewContentModeCenter;
_backgroundImage.layer.masksToBounds = YES;
_backgroundImage.layer.cornerRadius = 4.0;
_backgroundImage.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:_backgroundImage];
_titleLabel = [[UILabel alloc] init];
_titleLabel.numberOfLines = 2;
_titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_titleLabel.textColor = HEXCOLOR(0x333333);
_titleLabel.font = [UIFont systemFontOfSize:15];
[self.contentView addSubview:_titleLabel];
_timeLabel = [[UILabel alloc] init];
_timeLabel.numberOfLines = 1;
_timeLabel.textColor = HEXCOLOR(0xbbbbbb);
_timeLabel.font = [UIFont systemFontOfSize:14];
[self.contentView addSubview:_timeLabel];
}
return self;
}
- (void)setModel:(CNNewsoundBaseModel *)model{
_model = model;
_titleLabel.text = model.title;
_timeLabel.text = model.createDate;
[self layoutSubviews];
}
- (void)layoutSubviews{
[_backgroundImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.mas_left).with.offset(10);
make.right.equalTo(self.mas_right).with.offset(-10);
make.top.equalTo(self.mas_top).with.offset(5);
make.bottom.equalTo(self.mas_bottom).with.offset(-5);
}];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self->_backgroundImage.mas_left).with.offset(5);
make.top.equalTo(self->_backgroundImage.mas_top).with.offset(5);
make.right.equalTo(self->_backgroundImage.mas_right).with.offset(-5);
}];
[_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self->_backgroundImage.mas_left).with.offset(5);
make.right.equalTo(self->_backgroundImage.mas_right).with.offset(-5);
make.bottom.equalTo(self->_backgroundImage.mas_bottom).with.offset(-5);
}];
}
- (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
}
@end