CNLiveCMineInteDetailHeaderView.m
7.02 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
134
135
136
137
138
139
140
141
142
143
//
// CNLiveCMineInteDetailHeaderView.m
// CNLiveCMineModule
//
// Created by open on 2021/12/29.
//
#import "CNLiveCMineInteDetailHeaderView.h"
@interface CNLiveCMineInteDetailHeaderView()
@property (nonatomic, strong) UILabel * inteLabel;
@property (nonatomic, strong) QMUIButton * dateButton;
@property (nonatomic, strong) UILabel * spendLabel;//支出
@property (nonatomic, strong) UILabel * obtaLabel;//获取
@end
@implementation CNLiveCMineInteDetailHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addSubview:self.inteLabel];
[self addSubview:self.dateButton];
[self addSubview:self.obtaLabel];
[self addSubview:self.spendLabel];
}
return self;
}
-(void)setDetailModel:(CNLiveCMineInteDetailModel *)detailModel
{
_detailModel = detailModel;
NSMutableAttributedString * coin_string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@积分",[detailModel.currentInte isNotBlank]?detailModel.currentInte:@"0"]];
[coin_string addAttribute:NSFontAttributeName value:UIFontCNMake(12) range:[coin_string.string rangeOfString:@"积分"]];
[coin_string addAttribute:NSFontAttributeName value:UIFontBoldCNMake(35) range:NSMakeRange(0, [coin_string.string rangeOfString:@"积分"].location)];
self.inteLabel.attributedText = coin_string;
NSMutableAttributedString * spend_string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"获取:%@",[detailModel.obtainIntegral isNotBlank]?detailModel.obtainIntegral:@"0"]];
[spend_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:11] range:[spend_string.string rangeOfString:@"获取:"]];
[spend_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, [spend_string.string rangeOfString:@"获取:"].location)];
self.spendLabel.attributedText = spend_string;
NSMutableAttributedString * obta_string = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"支出:%@",[detailModel.payIntegral isNotBlank]?detailModel.payIntegral:@"0"]];
[obta_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:11] range:[obta_string.string rangeOfString:@"支出:"]];
[obta_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, [obta_string.string rangeOfString:@"支出:"].location)];
self.obtaLabel.attributedText = obta_string;
NSArray * array = [detailModel.date_string componentsSeparatedByString:@"-"];
[self.dateButton setTitle:[NSString stringWithFormat:@"%@年%@月",array.firstObject,array.lastObject] forState:UIControlStateNormal];
}
-(void)layoutSubviews
{
[super layoutSubviews];
__weak typeof(self) weakSelf = self;
[self.inteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.mas_equalTo(weakSelf).offset(10);
}];
[self.dateButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(weakSelf).offset(10);
make.top.mas_equalTo(weakSelf.inteLabel.mas_bottom).offset(30);
}];
[self.obtaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(weakSelf.dateButton);
make.right.mas_equalTo(weakSelf.mas_right).offset(-5);
}];
[self.spendLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(weakSelf.dateButton);
make.right.mas_equalTo(weakSelf.obtaLabel.mas_left).offset(-5);
}];
}
-(void)pushDateSelectAction:(QMUIButton *)button
{
if (self.selectWithDateBlock) self.selectWithDateBlock();
}
#pragma mark =
- (UILabel *)inteLabel
{
if (!_inteLabel) {
_inteLabel = [[UILabel alloc] init];
_inteLabel.backgroundColor = [UIColor clearColor];
_inteLabel.textColor = UIColorHex(#FFFFFF);
NSMutableAttributedString * coin_string = [[NSMutableAttributedString alloc] initWithString:@"0积分"];
[coin_string addAttribute:NSFontAttributeName value:UIFontCNMake(12) range:[coin_string.string rangeOfString:@"积分"]];
[coin_string addAttribute:NSFontAttributeName value:UIFontBoldCNMake(35) range:NSMakeRange(0, [coin_string.string rangeOfString:@"积分"].location)];
_inteLabel.attributedText = coin_string;
}
return _inteLabel;
}
- (UILabel *)spendLabel
{
if (!_spendLabel) {
_spendLabel = [[UILabel alloc] init];
_spendLabel.backgroundColor = [UIColor clearColor];
_spendLabel.textColor = UIColorHex(#FFFFFF);
NSMutableAttributedString * spend_string = [[NSMutableAttributedString alloc] initWithString:@"获取:0"];
[spend_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:11] range:[spend_string.string rangeOfString:@"获取:"]];
[spend_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, [spend_string.string rangeOfString:@"获取:"].location)];
_spendLabel.attributedText = spend_string;
}
return _spendLabel;
}
- (UILabel *)obtaLabel
{
if (!_obtaLabel) {
_obtaLabel = [[UILabel alloc] init];
_obtaLabel.backgroundColor = [UIColor clearColor];
_obtaLabel.textColor = UIColorHex(#FFFFFF);
NSMutableAttributedString * obta_string = [[NSMutableAttributedString alloc] initWithString:@"支出:0"];
[obta_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:11] range:[obta_string.string rangeOfString:@"支出:"]];
[obta_string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, [obta_string.string rangeOfString:@"支出:"].location)];
_obtaLabel.attributedText = obta_string;
}
return _obtaLabel;
}
-(QMUIButton *)dateButton
{
if (!_dateButton) {
_dateButton = [[QMUIButton alloc] init];
[_dateButton setImage:[CNLiveCMineService imageWithMineName:@"c_mine_content_date_tira"] forState:UIControlStateNormal];
[_dateButton setTitleColor:UIColorHex(0xFFFFFF) forState:UIControlStateNormal];
_dateButton.titleLabel.font = [UIFont systemFontOfSize:12];
_dateButton.backgroundColor = [UIColor clearColor];
_dateButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
_dateButton.spacingBetweenImageAndTitle = 2.5;
_dateButton.imageEdgeInsets = UIEdgeInsetsMake(0, 2.5, 0, 2.5);
_dateButton.imagePosition = QMUIButtonImagePositionLeft;
[_dateButton addTarget:self action:@selector(pushDateSelectAction:) forControlEvents:UIControlEventTouchUpInside];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM"];
NSArray * dateArray = [[dateFormatter stringFromDate:[NSDate date]] componentsSeparatedByString:@"-"];
NSString * s = [NSString stringWithFormat:@"%@年%@月",dateArray.firstObject,dateArray.lastObject];
[_dateButton setTitle:s forState:UIControlStateNormal];
}
return _dateButton;
}
@end