CNLIveCategoryCell.m
2.9 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
94
95
96
97
98
99
100
101
102
//
// CNLIveCategoryCell.m
// CNLiveCServiceModule
//
// Created by CNLive on 2021/12/1.
//
#import "CNLIveCategoryCell.h"
@interface CNLIveCategoryCell()
@property (nonatomic, strong) UIImageView *logoView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *subTitle;
@property (nonatomic, strong) UIImageView *rightImage;
@end
@implementation CNLIveCategoryCell
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self.contentView addSubview:self.logoView];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.subTitle];
[self.contentView addSubview:self.rightImage];
}
return self;
}
-(void)layoutSubviews
{
[super layoutSubviews];
[self.logoView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.centerY.equalTo(self.contentView);
make.height.width.offset(40);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.logoView.mas_right).offset(12.5);
make.bottom.equalTo(self.logoView.mas_centerY).offset(-2);
make.right.equalTo(self.contentView);
}];
[self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self).offset(-15);
make.width.height.offset(18);
make.centerY.equalTo(self);
}];
[self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel);
make.top.equalTo(self.logoView.mas_centerY).offset(2);
make.right.equalTo(self.rightImage.mas_left).offset(-5);
}];
}
#pragma mark - Setting&&Getting
- (void)setModel:(CNLiveSearchModel *)model
{
_model = model;
[self.logoView sd_setImageWithURL:[NSURL URLWithString:model.icon]];
self.titleLabel.text = model.title;
self.subTitle.text = model.desc;
[self layoutSubviews];
}
- (UIImageView *)logoView{
if (!_logoView) {
_logoView = [[UIImageView alloc] init];
_logoView.clipsToBounds = YES;
_logoView.layer.cornerRadius = 22.5;
}
return _logoView;
}
- (UILabel *)titleLabel
{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = UIFontMake(15);
_titleLabel.textColor = CNLiveColorWithHexString(@"#666666");
_titleLabel.textAlignment = NSTextAlignmentLeft;
}
return _titleLabel;
}
- (UILabel *)subTitle
{
if (!_subTitle) {
_subTitle = [[UILabel alloc] init];
_subTitle.textColor = CNLiveColorWithHexString(@"#A9A9A9");
_subTitle.font = UIFontMake(12);
}
return _subTitle;
}
- (UIImageView *)rightImage
{
if (!_rightImage) {
_rightImage = [[UIImageView alloc] init];
[_rightImage setImage:[UIImage loadCServiceBundle:@"service_right"]];
}
return _rightImage;
}
@end