IVTMeGrabCell.m
5.49 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
//
// IVTMeGrabCell.m
// IVTMeLive
//
// Created by XRG on 16/4/28.
// Copyright © 2016年 Joky. All rights reserved.
//
#import "IVTMeGrabCell.h"
#import "Masonry.h"
#import "UIColor+IVTMeColor.h"
#import "UIFont+IVTMeFont.h"
@interface IVTMeGrabCell()
{
UILabel *name;
UILabel *mark;
UILabel *good;
UIImageView *head;
UIImageView *sex;
UIImageView *crow;
}
@end
@implementation IVTMeGrabCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
_headIcon = [[UIImageView alloc] init];
_headIcon.image = [UIImage imageNamed:@"红包手气-头像2"];
_headIcon.layer.cornerRadius = _headIcon.bounds.size.width/2;
_headIcon.layer.masksToBounds = YES;
_headIcon.contentMode = UIViewContentModeScaleAspectFill;
[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.centerY.equalTo(wself.contentView);
make.size.mas_equalTo(CGSizeMake(25, 25));
}];
_name = [[UILabel alloc]init];
[self.contentView addSubview:_name];
_name.backgroundColor = [UIColor clearColor];
_name.textColor = [UIColor YXColorWithHexCode:@"#343434"];
_name.font = [UIFont YXFontOfSize:14];
_name.text = [[IVTAccountTool getNickName] base64DecodedToString];
_name.textAlignment = NSTextAlignmentLeft;
[_name mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wself.contentView);
make.left.equalTo(_headIcon.mas_right).with.offset(7);
make.size.mas_equalTo(CGSizeMake(90, 15));
}];
_gold = [[UIImageView alloc]init];
_gold.image = [UIImage imageNamed:@"中国币"];
[self.contentView addSubview:_gold];
[_gold mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wself.contentView);
make.right.equalTo(wself.contentView).with.offset(-12);
make.size.mas_equalTo(CGSizeMake(13, 13));
}];
_mark = [[UILabel alloc]init];
[self.contentView addSubview:_mark];
_mark.backgroundColor = [UIColor clearColor];
_mark.textColor = [UIColor YXColorWithHexCode:@"#8A0000"];
_mark.font = [UIFont YXFontOfSize:10];
_mark.text = @"20";
_mark.textAlignment = NSTextAlignmentCenter;
[_mark mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wself.contentView);
make.right.equalTo(_gold.mas_left).with.offset(-6);
make.size.mas_equalTo(CGSizeMake(30, 12));
}];
_sex = [[UIImageView alloc]init];
_sex.image = [UIImage imageNamed:@"性别女"];
[self.contentView addSubview:_sex];
[_sex sizeToFit];
[_sex mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wself.contentView);
make.right.equalTo(_mark.mas_left).with.offset(-10);
make.size.mas_equalTo(CGSizeMake(11.5, 14));
}];
_lineView =[[UIView alloc]init];
[self.contentView addSubview:_lineView];
_lineView.backgroundColor = [UIColor IVTSeparatorColor];
[_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(wself.contentView.mas_top).with.offset(35);
make.height.mas_equalTo(@(0.5));
make.leading.equalTo(wself.contentView.mas_leading);
make.trailing.equalTo(wself.contentView.mas_trailing);
}];
}
return self;
}
- (void)setCellModel:(IVTGetRedPackedModel *)cellModel
{
__unsafe_unretained typeof (self) wself = self;
// 姓名
_name.text = cellModel.name;
// 头像
[_headIcon sd_setImageWithURL:[NSURL URLWithString:cellModel.avatar] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
// self.headIcon.alpha = 0.0;
// [UIView transitionWithView:self.headIcon
// duration:1.0
// options:UIViewAnimationOptionTransitionCrossDissolve
// animations:^{
// [self.headIcon setImage:image];
// self.headIcon.alpha = 1.0;
// } completion:NULL];
}];
// 性别
if ([cellModel.sex isEqualToString:@"male"]) {
[_sex setImage:[UIImage imageNamed:@"性别男"]];
}else if ([cellModel.sex isEqualToString:@"female"]){
[_sex setImage:[UIImage imageNamed:@"性别女"]];
} else {
[_sex setImage:[UIImage imageNamed:@"性别女"]];
}
[_sex mas_updateConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(wself.contentView);
make.left.equalTo(_name.mas_right).with.offset(4);
make.size.mas_equalTo(CGSizeMake(11.5, 14));
}];
// 金币
_mark.text = [NSString stringWithFormat:@"%@",cellModel.money];
// 用户ID
_userId = cellModel.userId;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end