CNLiveSelectSubView.m
1.53 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
//
// CNLiveSelectSubView.m
// CNLiveMyOrder
//
// Created by 殷巧娟 on 2019/6/12.
//
#import "CNLiveSelectSubView.h"
#import "CNLiveBaseKit.h"
@interface CNLiveSelectSubView ()
{
NSString *_imgName;
NSString *_title;
}
@property (nonatomic, strong) UIImageView *subImgView;
@property (nonatomic, strong) UILabel *titleLab;
@end
@implementation CNLiveSelectSubView
- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title imgName:(NSString *)imgName
{
self = [super initWithFrame:frame];
if (self) {
_title = title;
_imgName = imgName;
[self initSubView];
}
return self;
}
- (void)initSubView {
[self addSubview:self.subImgView];
self.subImgView.centerX = self.width*0.5;
[self addSubview:self.titleLab];
self.titleLab.top = self.subImgView.bottom+15;
}
- (void)reloadUI {
self.titleLab.font = UIFontCNMake(12);
}
- (UIImageView *)subImgView {
if (!_subImgView) {
_subImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 15, 26, 26)];
_subImgView.contentMode = UIViewContentModeScaleAspectFit;
_subImgView.image = [UIImage imageNamed:_imgName];
}
return _subImgView;
}
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.width, 14)];
_titleLab.text = _title;
_titleLab.textColor = RGBA(46, 45, 45, 1);
_titleLab.font = UIFontCNMake(12);
_titleLab.textAlignment = NSTextAlignmentCenter;
}
return _titleLab;
}
@end