IVTMeGiftCell.m
3.84 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
//
// IVTMeGiftCell.m
// IVTMeLive
//
// Created by XRG on 16/6/6.
// Copyright © 2016年 Joky. All rights reserved.
//
#import "IVTMeGiftCell.h"
@interface IVTMeGiftCell ()
{
UIImageView *_gift;
UIButton *_lianFa;
UILabel *_money;
UIImageView *_chineseCoin;
UILabel *_jingyan;
}
@end
@implementation IVTMeGiftCell
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self prepareUI];
}
return self;
}
-(void)prepareUI{
__unsafe_unretained typeof (self) wself = self;
_gift = [[UIImageView alloc]init];
[self.contentView addSubview:_gift];
[_gift mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(wself.contentView.mas_top).with.offset(10);
make.left.equalTo(wself.contentView.mas_left).with.offset(10);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
_lianFa = [UIButton buttonWithType:UIButtonTypeCustom];
[self.contentView addSubview:_lianFa];
[_lianFa mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(wself.contentView.mas_top).with.offset(5);
make.left.equalTo(_gift.mas_right).with.offset(10);
make.size.mas_equalTo(CGSizeMake(10, 10));
}];
_money = [[UILabel alloc]init];
_money.textColor = [UIColor IVTLightRedColor];
_money.font = [UIFont YXFontOfSize:11];
[self.contentView addSubview:_money];
[_money mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_gift.mas_bottom).with.offset(10);
make.centerX.equalTo(wself.contentView).with.offset(10);
make.size.mas_equalTo(CGSizeMake(30, 15));
}];
_chineseCoin = [[UIImageView alloc]init];
_chineseCoin.image = [UIImage imageNamed:@"小中国币(礼物下面)"];
[self.contentView addSubview:_chineseCoin];
[_chineseCoin mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_gift.mas_bottom).with.offset(10);
make.right.equalTo(_money.mas_left).with.offset(-3);
make.size.mas_equalTo(CGSizeMake(15, 15));
}];
_jingyan = [[UILabel alloc]init];
_jingyan.textColor = [UIColor YXColorWithHexCode:@"787878"];
_jingyan.font = [UIFont YXFontOfSize:10];
_jingyan.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:_jingyan];
[_jingyan mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_gift.mas_centerX);
make.top.equalTo(_chineseCoin.mas_bottom).with.offset(5);
make.size.mas_equalTo(CGSizeMake(60, 15));
}];
}
- (void)setEntity:(NSDictionary *)entity{
_entity = entity;
NSLog(@"----%@",self.entity[@"icon"]);
NSString *imageUrlString = [[NSString stringWithFormat:@"%@",self.entity[@"icon"]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[_gift sd_setImageWithURL:[NSURL URLWithString:imageUrlString] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
}];
if ([self.entity[@"type"] integerValue] == 0) {
[_lianFa setImage:[UIImage imageNamed:@"连发"] forState:UIControlStateNormal];
[_lianFa setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateSelected];
_lianFa.hidden = NO;
if ([self.entity[@"isSelected"] integerValue]) {
_lianFa.selected = YES;
}
else{
_lianFa.selected = NO;
}
}
else{
[_lianFa setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateNormal];
if ([self.entity[@"isSelected"] integerValue]) {
_lianFa.hidden = NO;
}
else{
_lianFa.hidden = YES;
}
}
_money.text = [NSString stringWithFormat:@"%@",self.entity[@"price"]];
_jingyan.text = [NSString stringWithFormat:@"经验:%@",self.entity[@"exp"]];
}
@end