LVCUGCLivePlayerCell.m
6.44 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//
// LVCUGCLivePlayerCell.m
// LiveVideoCloud
//
// Created by cnliveJunBo on 17/3/28.
// Copyright © 2017年 cnlive. All rights reserved.
//
#import "LVCUGCLivePlayerCell.h"
@interface LVCUGCLivePlayerCell()
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *locationLabel;
@property (nonatomic, strong) UILabel *countLabel;
@property (nonatomic, strong) UILabel *lookLabel;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *stateLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *lineView;
@end
@implementation LVCUGCLivePlayerCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.contentView.backgroundColor = [UIColor whiteColor];
[self.contentView addSubview:self.iconView];
[self.contentView addSubview:self.nameLabel];
[self.contentView addSubview:self.locationLabel];
[self.contentView addSubview:self.countLabel];
[self.contentView addSubview:self.lookLabel];
[self.contentView addSubview:self.imageView];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.lineView];
}
return self;
}
#pragma mark - SetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- (void)setModel:(LVCUGCLivePlayerModel *)model {
if (_model != model) {
_model = model;
}
_titleLabel.text = model.activityName; // 标题
NSString *path = [[NSBundle mainBundle] pathForResource:@"timg" ofType:@"jpeg"];// 封面图
UIImage *image = [UIImage imageWithContentsOfFile:path];
[_imageView sd_setImageWithURL:[NSURL URLWithString:model.coverImgUrl] placeholderImage:image];
if (model.extensionName.length > 0) {
_nameLabel.text = model.extensionName;
} else {
_nameLabel.text = @"我的昵称";
}
// NSString *iconPath = [[NSBundle mainBundle] pathForResource:@"头像" ofType:@"jpg"];
// UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath];
UIImage *iconImage = [UIImage imageWithData:[NSData
dataWithContentsOfURL:[NSURL URLWithString:[UserInformationModel manager].faceUrl]]];
[_iconView sd_setImageWithURL:[NSURL URLWithString:model.extensionIcon] placeholderImage:iconImage];
switch ([model.activityStatus intValue]) {
case -2: // 异常
_stateLabel.text = @"异常";
break;
case 0: // 未开始
_stateLabel.text = @"未开始";
break;
case 1: // 已开始
_stateLabel.text = @"正直播";
break;
case 2: // 已结束
_stateLabel.text = @"已结束";
break;
case 4: // 已离线
_stateLabel.text = @"已离线";
break;
default:
break;
}
}
#pragma mark - SetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- (UIImageView *)iconView {
if (!_iconView) {
_iconView = [[UIImageView alloc] init];
_iconView.frame = CGRectMake(10, 10, 50, 50);
_iconView.contentMode = UIViewContentModeScaleAspectFit;
_iconView.layer.cornerRadius = 25;
_iconView.layer.masksToBounds = YES;
}
return _iconView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 15, SCREEN_WIDTH - 140, 20)];
_nameLabel.text = @"这是我的昵称";
_nameLabel.textColor = [UIColor grayColor];
}
return _nameLabel;
}
- (UILabel *)locationLabel {
if (!_locationLabel) {
_locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(70, 40, SCREEN_WIDTH - 140, 20)];
_locationLabel.text = @"这是我的地址";
_locationLabel.font = [UIFont systemFontOfSize:13];
_locationLabel.textColor = [UIColor grayColor];
}
return _locationLabel;
}
- (UILabel *)countLabel {
if (!_countLabel) {
_countLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 65, 15, 60, 20)];
_countLabel.text = @"13244";
_countLabel.textAlignment = NSTextAlignmentRight;
_countLabel.textColor = [UIColor orangeColor];
}
return _countLabel;
}
- (UILabel *)lookLabel {
if (!_lookLabel) {
_lookLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 45, 35, 40, 20)];
_lookLabel.text = @"在看";
_lookLabel.font = [UIFont systemFontOfSize:13];
_lookLabel.textAlignment = NSTextAlignmentRight;
_lookLabel.textColor = [UIColor grayColor];
}
return _lookLabel;
}
- (UIImageView *)imageView {
if (!_imageView) {
_imageView = [[UIImageView alloc] init];
_imageView.frame = CGRectMake(0, 70, SCREEN_WIDTH, SCREEN_WIDTH);
_imageView.contentMode = UIViewContentModeScaleAspectFill;
_imageView.backgroundColor = [UIColor colorWithRed:(230/255) green:(241/255) blue:(243/255) alpha:1];
_imageView.clipsToBounds = YES;
[_imageView addSubview:self.stateLabel];
}
return _imageView;
}
- (UILabel *)stateLabel {
if (!_stateLabel) {
_stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 70, 10, 60, 20)];
_stateLabel.font = [UIFont systemFontOfSize:13];
_stateLabel.textAlignment = NSTextAlignmentCenter;
_stateLabel.textColor = [UIColor whiteColor];
_stateLabel.backgroundColor = [UIColor colorWithRed:(250/255) green:(246/255) blue:(246/255) alpha:0.3];
_stateLabel.layer.cornerRadius = 10;
_stateLabel.layer.masksToBounds = YES;
_stateLabel.text = @"直播";
_stateLabel.layer.borderColor = [UIColor whiteColor].CGColor;
_stateLabel.layer.borderWidth = 1;
}
return _stateLabel;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, SCREEN_WIDTH + 75, SCREEN_WIDTH, 20)];
_titleLabel.textColor = [UIColor grayColor];
_titleLabel.text = @"这是一个标题";
}
return _titleLabel;
}
- (UIView *)lineView {
if (!_lineView) {
_lineView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_WIDTH + 100, SCREEN_WIDTH, 10)];
_lineView.backgroundColor = [UIColor colorWithRed:(217/255.0) green:(255/255.0) blue:(239/255.0) alpha:1.0];
}
return _lineView;
}
@end