CNLiveUserSettingTableViewCell.m
4.54 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
//
// CNLiveUserSettingTableViewCell.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/25.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "CNLiveUserSettingTableViewCell.h"
@interface CNLiveUserSettingTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailsLabel;
@property (nonatomic, strong) UIImageView *leftImage;
@property (nonatomic, strong) UIImageView *line;
@end
@implementation CNLiveUserSettingTableViewCell
static const NSInteger margin = 10;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.numberOfLines = 1;
_titleLabel.textColor = HEXCOLOR(0x333333);
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:_titleLabel];
_detailsLabel = [[UILabel alloc] init];
_detailsLabel.numberOfLines = 1;
_detailsLabel.textColor = HEXCOLOR(0x666666);
_detailsLabel.font = [UIFont systemFontOfSize:13];
[self addSubview:_detailsLabel];
_leftImage = [[UIImageView alloc] init];
_leftImage.contentMode = UIViewContentModeScaleAspectFill;
_leftImage.layer.cornerRadius = 10;
_leftImage.layer.masksToBounds = YES;
_leftImage.image = [UIImage imageNamed:@"cnlive_my_next"];
[self addSubview:_leftImage];
_line = [[UIImageView alloc] init];
_line.backgroundColor = Color_Line;
[self addSubview:_line];
}
return self;
}
- (void)setName:(NSString *)name{
_name = name;
_titleLabel.text = name;
}
- (void)setType:(NSString *)type{
_type = type;
[self layoutSubviews];
}
- (void)layoutSubviews{
_titleLabel.frame = CGRectMake(margin, 0, 180, CGRectGetHeight(self.bounds));
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if([_type isEqualToString:@"0"]){
_leftImage.hidden = YES;
_detailsLabel.hidden = NO;
//昵称
[_detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_top).with.offset(0);
make.right.equalTo(self.mas_right).with.offset(-10);
make.height.offset(CGRectGetHeight(self.bounds));
}];
NSString *name = [userDefaults valueForKey:@"user_name"];
_detailsLabel.text = name;
}
else if ([_type isEqualToString:@"1"]){
_detailsLabel.hidden = YES;
_leftImage.hidden = NO;
//头像
_leftImage.frame = CGRectMake(CGRectGetMaxX(self.bounds)-CGRectGetHeight(self.bounds)+10-margin, 5, CGRectGetHeight(self.bounds)-10, CGRectGetHeight(self.bounds)-10);
_leftImage.layer.cornerRadius = (CGRectGetHeight(self.bounds)-10)/2.0;
NSString *pic = [userDefaults valueForKey:@"user_headimg"];
[_leftImage sd_setImageWithURL:[NSURL URLWithString:pic] placeholderImage:[UIImage imageNamed:@"cnlive_my_header"]];
}
else if ([_type isEqualToString:@"2"]){
_leftImage.hidden = YES;
_detailsLabel.hidden = NO;
//手机号
[_detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_top).with.offset(0);
make.right.equalTo(self.mas_right).with.offset(-10);
make.height.offset(CGRectGetHeight(self.bounds));
}];
NSString *phone = [userDefaults valueForKey:@"user_phone"];
_detailsLabel.text = phone&&![phone isEqualToString:@""]?phone:CustomStr(@"PhoneNumberIsUnbound");
}
else if ([_type isEqualToString:@"3"]){
_leftImage.hidden = YES;
_detailsLabel.hidden = NO;
//邮箱
[_detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_top).with.offset(0);
make.right.equalTo(self.mas_right).with.offset(-10);
make.height.offset(CGRectGetHeight(self.bounds));
}];
NSString *email = [userDefaults valueForKey:@"user_email"];
_detailsLabel.text = email&&![email isEqualToString:@""]?email:CustomStr(@"EmailIsUnbound");
}
else if ([_type isEqualToString:@"4"]){
//密码
_detailsLabel.hidden = YES;
_leftImage.hidden = YES;
}
_line.frame = CGRectMake(0, 0, MainScreenWidth, Line_Height);
}
@end