ScoreLevelView.m
4.4 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
//
// ScoreLevelView.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "ScoreLevelView.h"
@interface ScoreLevelView ()
@property (nonatomic, strong) UIImageView *cardIV;
@property (nonatomic, strong) UILabel *curRankNameLab;
@property (nonatomic, strong) UILabel *totalPointsLab;
@property (nonatomic, strong) UIImageView *rewardIV;
@property (nonatomic, strong) UIButton *rulesBtn;
@property (nonatomic, strong) UILabel *curRankLab;
@property (nonatomic, strong) UILabel *nextRankLab;
@end
@implementation ScoreLevelView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self debugViewShowBorder];
[self addSubview:self.cardIV];
[self addSubview:self.curRankNameLab];
[self addSubview:self.totalPointsLab];
[self addSubview:self.rewardIV];
[self addSubview:self.rulesBtn];
[self addSubview:self.curRankLab];
[self addSubview:self.nextRankLab];
CGFloat h = 150*(kScreenWidth - 30)/345;
[self.cardIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.bottom.equalTo(self).offset(-24);
make.height.equalTo(@(h));
}];
[self.rewardIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.cardIV);
make.left.equalTo(self.curRankNameLab.mas_right).offset(23);
make.size.mas_equalTo(CGSizeMake(79, 78));
}];
[self.rulesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.cardIV).offset(14);
make.right.equalTo(self.cardIV).offset(-9);
make.size.mas_equalTo(CGSizeMake(64, 21));
}];
}
return self;
}
- (void)updateData:(MyScoreModel *)scoreModel {
self.curRankNameLab.text = scoreModel.rank_name;
self.totalPointsLab.text = [NSString stringWithFormat:@"总积分:%ld", scoreModel.total_points];
[self.rewardIV yy_setImageWithURL:[NSURL URLWithString:scoreModel.reward_img] placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
self.curRankLab.text = scoreModel.cur_rank;
self.nextRankLab.text = scoreModel.next_rank;
[self.curRankNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardIV).offset(20);
make.top.equalTo(self.cardIV).offset(15);
}];
[self.totalPointsLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.curRankNameLab);
make.top.equalTo(self.curRankNameLab.mas_bottom).offset(16);
}];
[self.curRankLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.cardIV).offset(15);
make.bottom.equalTo(self.cardIV).offset(-12);
}];
[self.nextRankLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.cardIV).offset(-17);
make.bottom.equalTo(self.cardIV).offset(-41);
}];
}
#pragma mark - lazy
- (UIImageView *)cardIV {
if (!_cardIV) {
_cardIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_card_jifen"]];
}
return _cardIV;
}
- (UILabel *)curRankNameLab {
if (!_curRankNameLab) {
_curRankNameLab = [UILabel labWithTextColor:DSWhite font:BoldFont(24)];
}
return _curRankNameLab;
}
- (UILabel *)totalPointsLab {
if (!_totalPointsLab) {
_totalPointsLab = [UILabel labWithTextColor:ColorFromHex(0x28525A) font:SysFont(14)];
}
return _totalPointsLab;
}
- (UIImageView *)rewardIV {
if (!_rewardIV) {
_rewardIV = [UIImageView new];
}
return _rewardIV;
}
- (UIButton *)rulesBtn {
if (!_rulesBtn) {
_rulesBtn = [UIButton btnWithTitle:@"积分规则" titleColor:DSWhite font:SysFont(12.0)];
_rulesBtn.backgroundColor = ColorFromHex(0x89CAD3);
[_rulesBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
[_rulesBtn cornerRadius:10.0];
}
return _rulesBtn;
}
- (UILabel *)curRankLab {
if (!_curRankLab) {
_curRankLab = [UILabel labWithTextColor:ColorFromHex(0x4599A8) font:BoldFont(12)];
}
return _curRankLab;
}
- (UILabel *)nextRankLab {
if (!_nextRankLab) {
_nextRankLab = [UILabel labWithTextColor:ColorFromHex(0x4599A8) font:BoldFont(12)];
_nextRankLab.textAlignment = NSTextAlignmentRight;
}
return _nextRankLab;
}
@end