IVTMeLiveListCell.m
8.81 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//
// IVTMeLiveListCell.m
// IVTMeLive
//
// Created by XRG on 16/4/15.
// Copyright © 2016年 Joky. All rights reserved.
//
#import "IVTMeLiveListCell.h"
#import "XMPPFramework.h"
@interface IVTMeLiveListCell()<UIGestureRecognizerDelegate>
@end
@implementation IVTMeLiveListCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
self.selectionStyle = UITableViewCellSelectionStyleNone;
_headIcon = [[UIImageView alloc] init];
_headIcon.image = [UIImage imageNamed:@"占位头像"];
_headIcon.clipsToBounds = YES;
// _headIcon.layer.cornerRadius = 34 / 2;
// _headIcon.userInteractionEnabled = YES;
[self.contentView addSubview:_headIcon];
__unsafe_unretained typeof (self) wself = self;
[_headIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(wself.contentView.mas_leading).with.offset(12);
make.top.equalTo(wself.contentView.mas_top).with.offset(10);
make.size.mas_equalTo(CGSizeMake(34, 34));
}];
UIButton *head = [UIButton buttonWithType:UIButtonTypeCustom];
head.backgroundColor =[UIColor clearColor];
[_headIcon addSubview:head];
[head mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(_headIcon);
}];
_name = [[UILabel alloc]init];
[self.contentView addSubview:_name];
_name.backgroundColor = [UIColor clearColor];
_name.textColor = [UIColor YXColorWithHexCode:@"#282828"];
_name.font = [UIFont YXFontOfSize:15];
_name.textAlignment = NSTextAlignmentLeft;
[_name mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(wself.contentView.mas_top).with.offset(12);
make.left.equalTo(_headIcon.mas_right).with.offset(11);
make.size.mas_equalTo(CGSizeMake(300, 14));
}];
_mark = [[UILabel alloc]init];
[self.contentView addSubview:_mark];
_mark.backgroundColor = [UIColor clearColor];
_mark.textColor = [UIColor YXColorWithHexCode:@"#8d8d8d"];
_mark.font = [UIFont YXFontOfSize:11];
_mark.textAlignment = NSTextAlignmentLeft;
[_mark mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_name.mas_bottom).with.offset(4);
make.left.equalTo(_headIcon.mas_right).with.offset(11);
make.size.mas_equalTo(CGSizeMake(210, 15));
}];
_imageVBig = [[UIImageView alloc]init];
_imageVBig.backgroundColor = [UIColor whiteColor];
_imageVBig.clipsToBounds = YES;
_imageVBig.layer.cornerRadius = 15;
_imageVBig.image = [UIImage imageNamed:@"占位头像"];
_imageVBig.frame = CGRectMake(13, 51, kScreenWidth - 26, kScreenWidth -30);
[self.contentView addSubview:_imageVBig];
_live = [[UIImageView alloc]init];
_live.image = [UIImage imageNamed:@"LIVE"];
[self.contentView addSubview:_live];
[_live mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(51, 19));
make.top.equalTo(_imageVBig.mas_top).with.offset(9);
make.leading.equalTo(_imageVBig.mas_leading).with.offset(20);
}];
_locationIcon = [[UIImageView alloc]init];
_locationIcon.image = [UIImage imageNamed:@"MeLocation"];
[self.contentView addSubview:_locationIcon];
[_locationIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(8, 10));
make.leading.equalTo(wself.contentView.mas_leading).with.offset(14);
make.top.equalTo(_imageVBig.mas_bottom).with.offset(12);
}];
_loaction = [[UILabel alloc]init];
[self.contentView addSubview:_loaction];
_loaction.backgroundColor = [UIColor clearColor];
_loaction.textColor = [UIColor YXColorWithHexCode:@"#000000" alpha:0.4];
_loaction.font = [UIFont YXFontOfSize:12];
_loaction.text = @"北京SOHO现代城";
_loaction.textAlignment = NSTextAlignmentLeft;
[_loaction mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_imageVBig.mas_bottom).with.offset(11);
make.left.equalTo(_locationIcon.mas_right).with.offset(5);
make.size.mas_equalTo(CGSizeMake(120, 13));
}];
_audienceIcon = [[UIImageView alloc]init];
_audienceIcon.image = [UIImage imageNamed:@"MeDedult"];
[self.contentView addSubview: _audienceIcon];
[ _audienceIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(8.5, 8.5));
make.leading.equalTo(wself.contentView.mas_trailing).with.offset(-24);
make.top.equalTo(_imageVBig.mas_bottom).with.offset(14);
}];
_audienceNum = [[UILabel alloc]init];
[self.contentView addSubview:_audienceNum];
_audienceNum.backgroundColor = [UIColor clearColor];
_audienceNum.textColor = [UIColor YXColorWithHexCode:@"#a3a3a3"];
_audienceNum.font = [UIFont YXFontOfSize:12];
_audienceNum.textAlignment = 2;
[ _audienceNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_imageVBig.mas_bottom).with.offset(13);
make.right.equalTo(_audienceIcon.mas_right).with.offset(-10);
make.size.mas_equalTo(CGSizeMake(35, 11));
}];
UILabel *spaceLine = [[UILabel alloc] init];
spaceLine.backgroundColor = [UIColor IVTBackgroundColor];
[self.contentView addSubview:spaceLine];
[ spaceLine mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(wself.contentView.mas_bottom).with.offset(0);
make.left.equalTo(wself.contentView.mas_left).with.offset(0);
make.size.mas_equalTo(CGSizeMake(kScreenWidth, 10));
}];
}
return self;
}
- (void)setPlayerModel:(IVTHotAndFollowVideoModel *)playerModel
{
_playerModel = playerModel;
// 用户名
_name.text = [playerModel.name base64DecodedToString];
_mark.text = [playerModel.liveRoomName base64DecodedToString];
// 用户所在城市
if (playerModel.city == nil) {
_loaction.text = @"难道在火星?";
}else{
_loaction.text = playerModel.city;
}
// 用户Image
[_headIcon sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",playerModel.portrait]] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_headIcon.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:_headIcon.bounds.size];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
//设置大小
maskLayer.frame = _headIcon.bounds;
//设置图形样子
maskLayer.path = maskPath.CGPath;
_headIcon.layer.mask = maskLayer;
_headIcon.alpha = 0.0;
[UIView transitionWithView:_headIcon
duration:1.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[_headIcon setImage:image];
_headIcon.alpha = 1.0;
} completion:NULL];
}];
// 封面Image
[_imageVBig sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",playerModel.portrait]] placeholderImage:[UIImage imageNamed:@"直播大厅展位图"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[_imageVBig.image circleImage:_imageVBig CGSize:CGSizeMake(15, 15)];
_imageVBig.alpha = 0.0;
[UIView transitionWithView:_imageVBig
duration:1.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[_imageVBig setImage:image];
_imageVBig.alpha = 1.0;
} completion:NULL];
}];
// 观看人数
_audienceNum.text = [NSString stringWithFormat:@"%d",playerModel.online_users];
// xmppRoomJid
_chatRoomAddr = playerModel.chatRoomJid;
// xmppUserJid
_userid = playerModel.userid;
}
//-(void)headClick:(id)sender{
//
// if (self.delegate && [self.delegate respondsToSelector:@selector(userIconClick:)]) {
// [self.delegate userIconClick:self.userid];
// }
//}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
}
@end