CNLiveMineButtonCell.m
2.36 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
//
// CNLiveMineButtonCell.m
// CNLiveMineModule
//
// Created by 153993236@qq.com on 11/12/2019.
// Copyright © 2019 153993236@qq.com. All rights reserved.
//
#import "CNLiveMineButtonCell.h"
#import <Masonry/Masonry.h>
#import "QMUIKit.h"
#import "CNLiveCategory.h"
#import "CNLiveBaseKit.h"
#import "CNLiveMineModel.h"
@interface CNLiveMineButtonCell()
@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UILabel *title;
@end
@implementation CNLiveMineButtonCell
#pragma mark - 生命周期
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.contentView.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:self.image];
[self.contentView addSubview:self.title];
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
[_image mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left);
make.right.equalTo(self.contentView.mas_right);
make.top.equalTo(self.contentView.mas_top);
make.height.offset(self.frame.size.height*2/3.0);
}];
[_title mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.image.mas_bottom);
make.left.equalTo(self.image.mas_left);
make.right.equalTo(self.image.mas_right);
make.bottom.equalTo(self.contentView.mas_bottom);
}];
}
#pragma mark - 数据
- (void)setModel:(CNLiveMineButtonModel *)model{
UIImage *xw_image = [self getImageWithImageName:model.image bundleName:@"CNLiveMineModule" targetClass:[self class]];
_image.image = xw_image;
_title.text = model.title;
_title.font = UIFontCNMake(12.0);
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
#pragma mark - 懒加载
- (UIImageView *)image{
if (!_image) {
_image = [[UIImageView alloc] init];
_image.contentMode = UIViewContentModeCenter;
}
return _image;
}
- (UILabel *)title {
if (!_title) {
_title = [[UILabel alloc] init];
_title.userInteractionEnabled = YES;
_title.numberOfLines = 1;
_title.lineBreakMode = NSLineBreakByTruncatingTail;
_title.textColor = [UIColor blackColor];
_title.textAlignment = NSTextAlignmentCenter;
_title.font = UIFontCNMake(12.0);
}
return _title;
}
@end