IVTMeManageCell.m
5.24 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
//
// IVTMeManageCell.m
// IVTMeLive
//
// Created by XRG on 16/5/13.
// Copyright © 2016年 Joky. All rights reserved.
//
#import "IVTMeManageCell.h"
#import "UIColor+IVTMeColor.h"
#import "UIFont+IVTMeFont.h"
#import "Masonry.h"
#import "NameSexLevelView.h"
@interface IVTMeManageCell()
{
NameSexLevelView *nameSexLevelView;
}
@property(nonatomic,strong)UIImageView *headIcon;
@property (nonatomic, strong)UILabel *name;
@property (nonatomic, strong)UILabel *mark;
@property (nonatomic,strong)UIImageView *grade;
@property (nonatomic,strong) UILabel *lelveNum;
@property (nonatomic,strong)UIImageView *sex;
@property (nonatomic,strong)UIView *lineView;
@property (nonatomic,strong)UIButton *follow;
@end
@implementation IVTMeManageCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
__unsafe_unretained typeof (self) wself = self;
self.selectionStyle = UITableViewCellSelectionStyleNone;
_headIcon = [[UIImageView alloc] init];
_headIcon.image = [UIImage imageNamed:@"占位头像"];
[self.contentView addSubview:_headIcon];
_headIcon.clipsToBounds = YES;
_headIcon.layer.cornerRadius = 40/2;
[_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(39.5, 39.5));
}];
nameSexLevelView = [[NameSexLevelView alloc]init];
nameSexLevelView.userNickNameColor = UIColorFromRGBAlphaHex(0x343434, 1.0);
[self.contentView addSubview:nameSexLevelView];
[nameSexLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(wself.contentView.mas_top).offset(10);
make.left.equalTo(_headIcon.mas_right).offset(10);
make.width.mas_equalTo(50);
make.height.mas_equalTo(18);
}];
_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.left.equalTo(_headIcon.mas_right).with.offset(10);
make.right.equalTo(wself.contentView.mas_right).with.offset(-50);
make.top.equalTo(nameSexLevelView.mas_bottom).offset(5);
make.height.mas_equalTo(15);
}];
// _follow =[UIButton buttonWithType:UIButtonTypeCustom];
// [_follow addTarget:self action:@selector(followClick:) forControlEvents:UIControlEventTouchUpInside];
// [self.contentView addSubview:_follow];
// [_follow mas_makeConstraints:^(MASConstraintMaker *make) {
// make.size.mas_equalTo(CGSizeMake(27.5, 27.5));
// make.top.equalTo(wself.contentView.mas_top).with.offset(16);
// make.trailing.equalTo(wself.contentView.mas_trailing).with.offset(-17);
// }];
UIImageView *lineImageView = [[UIImageView alloc]init];
lineImageView.backgroundColor = UIColorFromRGBAlphaHex(0xdcdcdc, 1.0);
[self.contentView addSubview:lineImageView];
[lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(wself.contentView.mas_left).offset(62);
make.bottom.equalTo(wself.contentView.mas_bottom);
make.width.mas_equalTo(kScreenWidth-62);
make.height.mas_equalTo(0.4);
}];
}
return self;
}
- (void)setEntity:(NSDictionary *)entity{
_entity = entity;
NSString *avatar =[NSString stringWithFormat:@"%@",[_entity objectForKey:@"avatar"]];
if ([avatar isEqualToString:@"http://api.me.cnlive.com/avatar.png"]) {
_headIcon.image = [UIImage imageNamed:@"用户详情--用户--占位头像"];
}else{
[_headIcon sd_setImageWithURL:[NSURL URLWithString:avatar] placeholderImage:[UIImage imageNamed:@"占位头像"]];
}
nameSexLevelView.userNickName = [_entity[@"name"] base64DecodedToString];
nameSexLevelView.userSex = _entity[@"sex"];
nameSexLevelView.userLevel = _entity[@"level"];
NSString *sexString = [_entity objectForKey:@"sex"];
if ([sexString isEqualToString:@"male"]) {
[_sex setImage:[UIImage imageNamed:@"性别男"]];
}else if ([sexString isEqualToString:@"female"]){
[_sex setImage:[UIImage imageNamed:@"性别女"]];
} else {
[_sex setImage:[UIImage imageNamed:@"性别女"]];
}
NSString *giftNumString = [NSString stringWithFormat:@"贡献%@蜜糖",[_entity objectForKey:@"sentgiftcount"]];
_mark.text =giftNumString;
NSString *level = [_entity objectForKey:@"level"];
_grade.image = [IVTAccountTool showLevel:level].image;
_lelveNum.text = level;
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end