NameSexLevelView.m
3.51 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
//
// NameSexLevelView.m
// IVTMeLiveTwo
//
// Created by XRG on 16/8/19.
// Copyright © 2016年 QLQ. All rights reserved.
//
#import "NameSexLevelView.h"
@interface NameSexLevelView ()
{
UILabel *userNickNameLabel;
UIImageView *userSexImageView;
UIImageView *userLevelStarImageView;
UILabel *levelNumberLabel;
}
@end
@implementation NameSexLevelView
- (instancetype)init{
self = [super init];
if (self) {
[self setupSubViews];
}
return self;
}
- (void)setupSubViews{
__weak __typeof(self)weakSelf = self;
userNickNameLabel = [[UILabel alloc]init];
userNickNameLabel.frame = CGRectMake(0, 0, 0, CGRectGetHeight(self.frame));
userNickNameLabel.textColor = [UIColor whiteColor];
userNickNameLabel.font = [UIFont boldSystemFontOfSize:15];
userNickNameLabel.textAlignment = NSTextAlignmentLeft;
[userNickNameLabel sizeToFit];
[self addSubview:userNickNameLabel];
userSexImageView = [[UIImageView alloc]init];
[self addSubview:userSexImageView];
[userSexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(userNickNameLabel.mas_right).offset(5);
make.centerY.equalTo(weakSelf.mas_centerY);
make.size.mas_equalTo(CGSizeMake(12, 14));
}];
userLevelStarImageView = [[UIImageView alloc]init];
userLevelStarImageView.userInteractionEnabled =YES;
[self addSubview:userLevelStarImageView];
[userLevelStarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(userSexImageView.mas_right).offset(5);
make.centerY.equalTo(weakSelf.mas_centerY);
make.size.mas_equalTo(CGSizeMake(28, 14));
}];
levelNumberLabel =[[UILabel alloc]init];
levelNumberLabel.textColor = [UIColor whiteColor];
levelNumberLabel.font = [UIFont YXFontOfSize:10];
[userLevelStarImageView addSubview:levelNumberLabel];
[levelNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(userLevelStarImageView.mas_right);
make.centerY.equalTo(userLevelStarImageView.mas_centerY);
make.size.mas_equalTo(CGSizeMake(14, 14));
}];
}
- (void)setUserNickName:(NSString *)userNickName{
_userNickName = userNickName;
userNickNameLabel.text = [_userNickName base64DecodedToString];
LRLog(@"userNick:%@,%@",userNickNameLabel.text,_userNickName);
[userNickNameLabel sizeToFit];
CGFloat width = CGRectGetWidth(userNickNameLabel.frame) + 50;
[self mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
}];
}
- (void)setUserNickNameColor:(UIColor *)userNickNameColor{
_userNickNameColor = userNickNameColor;
userNickNameLabel.textColor = _userNickNameColor;
}
- (void)setUserSex:(NSString *)userSex{
_userSex = userSex;
if ([_userSex isEqualToString:@"male"]) {
userSexImageView.image = [UIImage imageNamed:@"性别男"];
}else if([_userSex isEqualToString:@"female"]){
userSexImageView.image = [UIImage imageNamed:@"性别女"];
}else {
userSexImageView.image = [UIImage imageNamed:@"性别女"];
}
}
- (void)setUserLevel:(NSString *)userLevel{
_userLevel = userLevel;
levelNumberLabel.text = _userLevel;
userLevelStarImageView.image = [IVTAccountTool showLevel:userLevel].image;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end