forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointRecordCell.m
More file actions
74 lines (71 loc) · 3.03 KB
/
PointRecordCell.m
File metadata and controls
74 lines (71 loc) · 3.03 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
//
// PointRecordCell.m
// Coding_iOS
//
// Created by Ease on 15/8/5.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "PointRecordCell.h"
@interface PointRecordCell ()
@property (strong, nonatomic) UILabel *usageL, *timeL, *pointsLeftL, *pointsChangeL;
@end
@implementation PointRecordCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
if (!_usageL) {
_usageL = [UILabel labelWithFont:[UIFont systemFontOfSize:15] textColor:[UIColor colorWithHexString:@"0x222222"]];
[self.contentView addSubview:_usageL];
}
if (!_timeL) {
_timeL = [UILabel labelWithFont:[UIFont systemFontOfSize:12] textColor:[UIColor colorWithHexString:@"0x999999"]];
[self.contentView addSubview:_timeL];
}
if (!_pointsLeftL) {
_pointsLeftL = [UILabel labelWithFont:[UIFont systemFontOfSize:12] textColor:[UIColor colorWithHexString:@"0x999999"]];
[self.contentView addSubview:_pointsLeftL];
}
if (!_pointsChangeL) {
_pointsChangeL = [UILabel labelWithFont:[UIFont systemFontOfSize:15] textColor:[UIColor colorWithHexString:@"0x3bbd79"]];
[self.contentView addSubview:_pointsChangeL];
}
[_usageL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(kPaddingLeftWidth);
make.top.equalTo(self.contentView).offset(10);
make.height.mas_equalTo(25);
}];
[_timeL mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
make.centerY.equalTo(_usageL);
make.height.mas_equalTo(20);
}];
[_pointsLeftL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(kPaddingLeftWidth);
make.centerY.equalTo(_pointsChangeL);
make.height.mas_equalTo(20);
}];
[_pointsChangeL mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
make.bottom.equalTo(self.contentView).offset(-10);
make.height.mas_equalTo(25);
}];
}
return self;
}
- (void)setCurRecord:(PointRecord *)curRecord{
_curRecord = curRecord;
if (!_curRecord) {
return;
}
_usageL.text = _curRecord.usage;
_timeL.text = [_curRecord.created_at stringWithFormat:@"yyyy-MM-dd hh:mm:ss"];
_pointsLeftL.text = [NSString stringWithFormat:@"余额:%.2f", _curRecord.points_left.floatValue];
_pointsChangeL.text = [NSString stringWithFormat:@"%@%.2f", _curRecord.action.intValue == 1? @"+": @"-", _curRecord.points_change.floatValue];
}
+ (CGFloat)cellHeight{
return 70.0;
}
@end