PraiseCell.m
3.7 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
//
// PraiseCell.m
// DreamSleep
//
// Created by peter on 2022/10/11.
//
#import "PraiseCell.h"
@interface PraiseCell ()
@property (nonatomic, strong) UIImageView *userIcon;
@property (nonatomic, strong) UILabel *userNameLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *tipLab;
@property (nonatomic, strong) UILabel *contentLab;
@end
@implementation PraiseCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self.contentView addSubview:self.userIcon];
[self.contentView addSubview:self.userNameLab];
[self.contentView addSubview:self.timeLab];
[self.contentView addSubview:self.tipLab];
[self.contentView addSubview:self.contentLab];
[self.userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.top.equalTo(self.contentView).offset(15);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(18);
make.right.equalTo(self.contentView).offset(-15);
}];
[self.tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userNameLab);
make.bottom.equalTo(self.userIcon);
}];
[self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.userIcon.mas_bottom).offset(7);
make.left.equalTo(self.contentView).offset(73);
make.right.equalTo(self.contentView).offset(-50);
}];
}
return self;
}
- (void)setPraiseModel:(PraiseModel *)praiseModel {
_praiseModel = praiseModel;
[self.userIcon yy_setImageWithURL:[NSURL URLWithString:praiseModel.user_profile] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(40, 40)]];
self.userNameLab.text = praiseModel.nick_name;
self.timeLab.text = praiseModel.publish_time;
[self.timeLab sizeToFit];
self.contentLab.text = praiseModel.content;
[self.userNameLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userIcon.mas_right).offset(12);
make.top.equalTo(self.userIcon);
make.right.equalTo(self.timeLab.mas_left).offset(-30);
}];
}
#pragma mark - lazy
- (UIImageView *)userIcon {
if (!_userIcon) {
_userIcon = [UIImageView new];
[_userIcon cornerRadius:20];
_userIcon.dk_alphaPicker = DKAlphaPickerWithAlphas(1.f, 0.5f, 0.1f);
}
return _userIcon;
}
- (UILabel *)userNameLab {
if (!_userNameLab) {
_userNameLab = [UILabel labWithFont:BoldFont(15)];
_userNameLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
}
return _userNameLab;
}
- (UILabel *)timeLab {
if (!_timeLab) {
_timeLab = [UILabel labWithFont:SysFont(12)];
_timeLab.textAlignment = NSTextAlignmentRight;
_timeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _timeLab;
}
- (UILabel *)tipLab {
if (!_tipLab) {
_tipLab = [UILabel labWithFont:SysFont(12)];
_tipLab.text = @"赞了你的动态";
_tipLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _tipLab;
}
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:SysFont(14)];
_contentLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .4), DSWhite);
}
return _contentLab;
}
@end