This commit is contained in:
2025-11-07 19:55:11 +08:00
parent 450798c8bd
commit 91d754b389

View File

@@ -12,8 +12,6 @@
@property (nonatomic, strong) UIImageView *cardImageView;
///
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) UIButton *plusButton;
///
- (void)renderWithTitle:(NSString *)title rank:(NSInteger)rank;
@@ -34,8 +32,6 @@
//
[self addSubview:self.avatarCircleView];
[self.cardImageView addSubview:self.titleLabel];
//
[self addSubview:self.plusButton];
//
[self.avatarCircleView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -47,7 +43,7 @@
[self.cardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.avatarCircleView.mas_bottom).offset(-34); //
make.left.right.equalTo(self);
make.height.mas_equalTo(148);
make.height.mas_equalTo(KBFit(148));
}];
@@ -57,13 +53,6 @@
make.top.equalTo(self.cardImageView).offset(84);
}];
[self.plusButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.cardImageView.mas_bottom).offset(12);
make.centerX.equalTo(self);
make.width.mas_equalTo(52);
make.height.mas_equalTo(28);
make.bottom.equalTo(self.mas_bottom); //
}];
}
- (void)renderWithTitle:(NSString *)title rank:(NSInteger)rank {
@@ -91,7 +80,7 @@
} break; //
}
self.cardImageView.image = image;
self.plusButton.backgroundColor = [theme colorWithAlphaComponent:0.3];
// KBTopThreeView
//
self.avatarCircleView.layer.borderColor = [UIColor colorWithRed:0.83 green:0.95 blue:0.27 alpha:1.0].CGColor;
@@ -129,17 +118,7 @@
return _titleLabel;
}
- (UIButton *)plusButton {
if (!_plusButton) {
_plusButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_plusButton setTitle:@"+" forState:UIControlStateNormal];
[_plusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
_plusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
_plusButton.layer.cornerRadius = 14.0;
_plusButton.layer.masksToBounds = YES;
}
return _plusButton;
}
// plusButton
@end
@@ -148,6 +127,8 @@
@property (nonatomic, strong) KBTopThreeCardView *leftCard;
@property (nonatomic, strong) KBTopThreeCardView *centerCard;
@property (nonatomic, strong) KBTopThreeCardView *rightCard;
/// KBTopThreeView
@property (nonatomic, strong) UIButton *plusButton;
@end
@implementation KBTopThreeView
@@ -164,27 +145,39 @@
[self addSubview:self.leftCard];
[self addSubview:self.centerCard];
[self addSubview:self.rightCard];
[self addSubview:self.plusButton];
//
[self.centerCard mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self).offset(8);
make.width.equalTo(self.mas_width).multipliedBy(1.0/3.0).offset(-12);
make.width.mas_equalTo(KBFit(96));
make.height.mas_equalTo(KBFit(180));
}];
//
CGFloat sideTopDelta = 12.0; // 12pt
[self.leftCard mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.centerCard);
make.top.equalTo(self.centerCard).offset(sideTopDelta);
make.right.equalTo(self.centerCard.mas_left).offset(-8);
make.width.equalTo(self.centerCard);
//
make.height.equalTo(self.centerCard);
}];
[self.rightCard mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.centerCard);
make.top.equalTo(self.centerCard).offset(sideTopDelta);
make.left.equalTo(self.centerCard.mas_right).offset(8);
make.width.equalTo(self.centerCard);
make.height.equalTo(self.centerCard);
}];
// /
[self.leftCard mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self).offset(-8); }];
[self.rightCard mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self).offset(-8); }];
// plusButton
[self.plusButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.centerCard.mas_bottom).offset(12);
make.centerX.equalTo(self);
make.width.mas_equalTo(52);
make.height.mas_equalTo(28);
make.bottom.equalTo(self).offset(-8);
}];
}
- (void)configWithItems:(NSArray<NSDictionary *> *)items {
@@ -207,5 +200,18 @@
- (KBTopThreeCardView *)centerCard { if (!_centerCard) _centerCard = [KBTopThreeCardView new]; return _centerCard; }
- (KBTopThreeCardView *)rightCard { if (!_rightCard) _rightCard = [KBTopThreeCardView new]; return _rightCard; }
@end
- (UIButton *)plusButton {
if (!_plusButton) {
_plusButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_plusButton setTitle:@"+" forState:UIControlStateNormal];
[_plusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
_plusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
_plusButton.layer.cornerRadius = 14.0;
_plusButton.layer.masksToBounds = YES;
//
_plusButton.backgroundColor = [[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] colorWithAlphaComponent:0.15];
}
return _plusButton;
}
@end