IVTMeUnGrabListView.m
8.6 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
//
// IVTMeUnGrabListView.m
// IVTMeLive
//
// Created by XRG on 16/4/28.
// Copyright © 2016年 Joky. All rights reserved.
//
#import "IVTMeUnGrabListView.h"
#import "Masonry.h"
#import "UIColor+IVTMeColor.h"
#import "UIFont+IVTMeFont.h"
#import "IVTMeGrabCell.h"
#import "IVTGetRedPackedModel.h"
@interface IVTMeUnGrabListView()<UITableViewDataSource,UITableViewDelegate>
{
UIView *_infoBgView;
UILabel *_nick;
UIImageView *_sex;
UIImageView *_grade;
UILabel *_lelveNum;
UIImageView *top;
}
@end
@implementation IVTMeUnGrabListView
-(void)willMoveToSuperview:(UIView *)newSuperview
{
[super willMoveToSuperview:newSuperview];
if(newSuperview == nil)
{
[[self subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
return ;
}
}
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
UIView *shadowView = [[UIView alloc]init];
shadowView.frame = [UIScreen mainScreen].bounds;
shadowView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.8];
self.shadowView = shadowView;
[self addSubview:shadowView];
/////////
CGFloat widthForPacket = (kScreenHeight - 448)/2;
//上半部分
top = [[UIImageView alloc]init];
top.image = [UIImage imageNamed:@"拆红包上滑后-红包打开"];
top.userInteractionEnabled = YES;
[self.shadowView addSubview:top];
[top mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_shadowView.mas_top).with.offset(widthForPacket);
make.centerX.equalTo(_shadowView);
}];
//中间
UIImageView *middle = [[UIImageView alloc]init];
middle.image = [UIImage imageNamed:@"未抢到红包-----手气---白色底"];
middle.userInteractionEnabled = YES;
[self.shadowView addSubview:middle];
[middle mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(top.mas_bottom).with.offset(-32);
make.centerX.equalTo(_shadowView);
}];
//关闭按钮
UIButton *close =[UIButton buttonWithType:UIButtonTypeCustom];
[close setBackgroundImage:[UIImage imageNamed:@"抢红包-关闭按钮"] forState:UIControlStateNormal];
close.enabled = YES;
[_shadowView addSubview:close];
[close mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(middle.mas_bottom).with.offset(-1);
make.centerX.equalTo(_shadowView);
make.size.mas_equalTo(CGSizeMake(270, 35));
}];
[close addTarget:self action:@selector(closeClick:) forControlEvents:UIControlEventTouchUpInside];
//头像
_headIcon = [[UIImageView alloc]init];
_headIcon.image = [UIImage imageNamed:@"抢红包头像"];
_headIcon.layer.masksToBounds = YES; //没这句话它圆不起来
_headIcon.layer.cornerRadius = 35.0; //设置图片圆角的尺度
[middle addSubview:_headIcon];
[_headIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(top.mas_top).with.offset(31);
make.centerX.equalTo(top.mas_centerX);
make.size.mas_equalTo(CGSizeMake(70, 70));
}];
_infoBgView = [[UIView alloc] init];
[middle addSubview:_infoBgView];
[_infoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_headIcon.mas_bottom).with.offset(12);
make.centerX.equalTo(middle);
}];
//昵称
_nick = [[UILabel alloc]init];
[_infoBgView addSubview:_nick];
_nick.textColor = [UIColor YXColorWithHexCode:@"5B5B5B"];
_nick.font = [UIFont YXFontOfSize:13];
[_nick mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_infoBgView.mas_top).with.offset(4);
make.bottom.equalTo(_infoBgView.mas_bottom).with.offset(-4);
make.left.equalTo(_infoBgView.mas_left);
}];
_sex = [[UIImageView alloc]init];
_sex.image = [UIImage imageNamed:@"性别女"];
[_infoBgView addSubview:_sex];
[_sex mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(_nick);
make.left.equalTo(_nick.mas_right).with.offset(5);
make.size.mas_equalTo(CGSizeMake(12, 14));
}];
_grade = [[UIImageView alloc]init];
_grade.image = [IVTAccountTool showLevel:[IVTAccountTool getLevel]].image;
[_infoBgView addSubview:_grade];
_grade.userInteractionEnabled =YES;
[_grade mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(_nick);
make.left.equalTo(_sex.mas_right).with.offset(5);
make.size.mas_equalTo(CGSizeMake(29, 14));
make.right.equalTo(_infoBgView.mas_right);
}];
_lelveNum =[[UILabel alloc]init];
_lelveNum.textColor = [UIColor whiteColor];
_lelveNum.font = [UIFont YXFontOfSize:10];
[_grade addSubview:_lelveNum];
[_lelveNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_grade.mas_top).with.offset(0);
make.right.equalTo(_grade.mas_right).with.offset(0);
make.size.mas_equalTo(CGSizeMake(14, 14));
}];
//手太慢,抢光了
_tips = [[UILabel alloc]init];
[middle addSubview:_tips];
_tips.textColor = [UIColor YXColorWithHexCode:@"DBCAB2"];
_tips.font = [UIFont YXFontOfSize:13];
[_tips mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_nick.mas_bottom).with.offset(17);
make.centerX.equalTo(middle);
}];
_grabList = [[UITableView alloc]init];
_grabList.separatorStyle = UITableViewCellSeparatorStyleNone;
_grabList.backgroundColor = [UIColor whiteColor];
[middle addSubview:_grabList];
_grabList.delegate =self;
_grabList.dataSource = self;
_grabList.showsHorizontalScrollIndicator = NO;
_grabList.showsVerticalScrollIndicator = NO;
[_grabList mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tips.mas_bottom).with.offset(52);
make.leading.equalTo(middle.mas_leading);
make.trailing.equalTo(middle.mas_trailing);
make.bottom.equalTo(close.mas_top);
}];
UIView *headView = [[UIView alloc]init];
[middle addSubview:headView];
headView.backgroundColor = [UIColor IVTBackgroundColor];
[headView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_tips.mas_bottom).with.offset(28);
make.leading.equalTo(middle.mas_leading);
make.trailing.equalTo(middle.mas_trailing);
make.height.mas_equalTo(24);
}];
}
return self;
}
- (void)setLevelString:(NSString *)levelString{
_levelString = levelString;
_lelveNum.text = [NSString stringWithFormat:@"%@",levelString];
}
- (void)setSexString:(NSString *)sexString{
_sexString = sexString;
if ([sexString isEqualToString:@"male"]) {
[_sex setImage:[UIImage imageNamed:@"性别男"]];
}else if ([sexString isEqualToString:@"female"]){
[_sex setImage:[UIImage imageNamed:@"性别女"]];
} else {
[_sex setImage:[UIImage imageNamed:@"性别女"]];
}
}
- (void)setNameString:(NSString *)nameString{
_nameString = nameString;
_nick.text = nameString;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _getRepacktedList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
IVTMeGrabCell *cell = [tableView dequeueReusableCellWithIdentifier:@"grabCell"];
if (!cell)
{
cell = [[IVTMeGrabCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"grabCell"];
cell.backgroundColor =[UIColor whiteColor];
}
IVTGetRedPackedModel *model = [self.getRepacktedList objectAtIndex:indexPath.row];
cell.cellModel = model;
return cell;
}
#pragma mark - table delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 35;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
-(void)closeClick:(UIButton *)button
{
[self.shadowView removeFromSuperview];
[self removeFromSuperview];
}
@end