CNLiveGoodsOrVideoHeaderView.m
4.56 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//
// CNLiveGoodsOrVideoHeaderView.m
// CNLiveCServiceModule
//
// Created by CNLive on 2021/12/1.
//
#import "CNLiveGoodsOrVideoHeaderView.h"
@interface CNLiveGoodsOrVideoHeaderView ()
@property (nonatomic, strong) UIImageView *LogoImage;
@property (nonatomic, strong) UILabel *titlelabel;
@property (nonatomic, strong) UILabel *subTitle;
@property (nonatomic, strong) QMUIButton *moreBtn;
@end
@implementation CNLiveGoodsOrVideoHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = kWhiteColor;
[self addSubview:self.LogoImage];
[self addSubview:self.titlelabel];
[self addSubview:self.subTitle];
[self addSubview:self.moreBtn];
[self makeSubViewsLayout];
}
return self;
}
-(void)makeSubViewsLayout
{
[self.LogoImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.centerY.equalTo(self);
make.width.height.offset(16.5);
}];
[self.titlelabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.centerY.equalTo(self);
}];
[self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titlelabel.mas_right).offset(8);
make.centerY.equalTo(self);
}];
[self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self).offset(-20);
make.centerY.equalTo(self);
}];
}
#pragma mark - Action
- (void)moreButtonClick
{
[CNLiveCServiceManagerBridge jumpWebVCWithUrl:_pageModel.moreUrl controller:[CNLiveCServiceManagerBridge viewControllerFromView:self]];
}
#pragma mark - Setting&&Getting
- (void)setPageModel:(CNliveServicePageModel *)pageModel
{
_pageModel = pageModel;
self.titlelabel.text = pageModel.blockName;
[self.titlelabel sizeToFit];
if (pageModel.blockSubTitle) {
self.subTitle.text = [NSString stringWithFormat:@"| %@",pageModel.blockSubTitle];
[self.subTitle sizeToFit];
}
if ([pageModel.blockName isEqualToString:@"热销排行"]) {
self.LogoImage.hidden = NO;
self.subTitle.hidden = NO;
self.moreBtn.hidden = NO;
UIColor *begin = CNLiveColorWithHexString(@"#FFF4F1");
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage gradientVerticalImageWithColors:@[begin,kWhiteColor] rect:self.bounds]];
self.titlelabel.textColor = CNLiveColorWithHexString(@"#FA7256");
[self.titlelabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.LogoImage.mas_right).offset(5);
make.centerY.equalTo(self);
}];
}else{
if ([pageModel.blockName isEqualToString:@"精品音频"]) {
self.moreBtn.hidden = YES;
}else{
self.moreBtn.hidden = NO;
}
self.LogoImage.hidden = YES;
self.subTitle.hidden = YES;
self.backgroundColor = kWhiteColor;
_titlelabel.textColor = CNLiveColorWithHexString(@"#333333");
[self.titlelabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.centerY.equalTo(self);
}];
}
}
- (UIImageView *)LogoImage
{
if (!_LogoImage) {
_LogoImage = [[UIImageView alloc] init];
[_LogoImage setImage:[UIImage loadCServiceBundle:@"service_hot"]];
_LogoImage.hidden = YES;
}
return _LogoImage;
}
- (UILabel *)titlelabel
{
if (!_titlelabel) {
_titlelabel = [[UILabel alloc] init];
_titlelabel.font = UIFontBoldMake(17);
_titlelabel.textColor = CNLiveColorWithHexString(@"#999999");
}
return _titlelabel;
}
- (UILabel *)subTitle
{
if (!_subTitle) {
_subTitle = [[UILabel alloc] init];
_subTitle.font = UIFontMake(12);
_subTitle.textColor = CNLiveColorWithHexString(@"#333333");
}
return _subTitle;
}
- (QMUIButton *)moreBtn
{
if (!_moreBtn) {
_moreBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
[_moreBtn setImage:[UIImage loadCServiceBundle:@"object_more"] forState:UIControlStateNormal];
[_moreBtn setTitle:@"更多" forState:UIControlStateNormal];
[_moreBtn setTitleColor:CNLiveColorWithHexString(@"#999695") forState:UIControlStateNormal];
_moreBtn.titleLabel.font = UIFontMake(12);
_moreBtn.imagePosition = QMUIButtonImagePositionRight;
[_moreBtn addTarget:self action:@selector(moreButtonClick) forControlEvents:UIControlEventTouchUpInside];
}
return _moreBtn;
}
@end