ScoreDetailCell.m
2.5 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
//
// ScoreDetailCell.m
// DreamSleep
//
// Created by peter on 2022/5/26.
//
#import "ScoreDetailCell.h"
@interface ScoreDetailCell ()
@property (nonatomic, strong) UILabel *itemNameLab;
@property (nonatomic, strong) UILabel *taskDateLab;
@property (nonatomic, strong) UILabel *pointsLab;
@end
@implementation ScoreDetailCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.backgroundColor = DSClearColor;
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.itemNameLab];
[self.contentView addSubview:self.taskDateLab];
[self.contentView addSubview:self.pointsLab];
}
return self;
}
- (void)setModel:(ScoreDetailModel *)model {
_model = model;
self.itemNameLab.text = model.item_name;
self.taskDateLab.text = model.task_date;
self.pointsLab.text = [NSString stringWithFormat:@"+%d", model.points];
[self.itemNameLab sizeToFit];
[self.taskDateLab sizeToFit];
[self.pointsLab sizeToFit];
[self.itemNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.top.equalTo(self.contentView).offset(24);
}];
[self.taskDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.itemNameLab);
make.top.equalTo(self.itemNameLab.mas_bottom).offset(8);
}];
[self.pointsLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.itemNameLab).offset(13);
make.right.equalTo(self.contentView).offset(-15);
}];
}
#pragma mark - lazy
- (UILabel *)itemNameLab {
if (!_itemNameLab) {
_itemNameLab = [UILabel labWithFont:BoldFont(15.0)];
_itemNameLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
}
return _itemNameLab;
}
- (UILabel *)taskDateLab {
if (!_taskDateLab) {
_taskDateLab = [UILabel labWithFont:SysFont(12.0)];
_taskDateLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3));
}
return _taskDateLab;
}
- (UILabel *)pointsLab {
if (!_pointsLab) {
_pointsLab = [UILabel labWithFont:SysFont(15.0)];
_pointsLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
_pointsLab.textAlignment = NSTextAlignmentRight;
}
return _pointsLab;
}
@end