1
This commit is contained in:
@@ -43,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(KBFit(148));
|
||||
make.height.mas_equalTo(KBFit(158));
|
||||
}];
|
||||
|
||||
|
||||
@@ -129,6 +129,9 @@
|
||||
@property (nonatomic, strong) KBTopThreeCardView *rightCard;
|
||||
/// 统一的底部加号按钮(移出卡片,放到 KBTopThreeView)
|
||||
@property (nonatomic, strong) UIButton *plusButton;
|
||||
/// 左右卡片底部也有 plus 按钮
|
||||
@property (nonatomic, strong) UIButton *leftPlusButton;
|
||||
@property (nonatomic, strong) UIButton *rightPlusButton;
|
||||
@end
|
||||
|
||||
@implementation KBTopThreeView
|
||||
@@ -146,6 +149,8 @@
|
||||
[self addSubview:self.centerCard];
|
||||
[self addSubview:self.rightCard];
|
||||
[self addSubview:self.plusButton];
|
||||
[self addSubview:self.leftPlusButton];
|
||||
[self addSubview:self.rightPlusButton];
|
||||
|
||||
// 横向均分布局
|
||||
[self.centerCard mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -173,11 +178,25 @@
|
||||
// 用 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.centerX.equalTo(self); // 或改为 equalTo(self.centerCard) 以严格与中卡居中
|
||||
make.width.mas_equalTo(60);
|
||||
make.height.mas_equalTo(28);
|
||||
make.bottom.equalTo(self).offset(-8);
|
||||
}];
|
||||
|
||||
// 左右 plus 按钮,同样底部对齐,用它们一起撑起视图
|
||||
[self.leftPlusButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.leftCard.mas_bottom).offset(12);
|
||||
make.centerX.equalTo(self.leftCard);
|
||||
make.width.height.equalTo(self.plusButton);
|
||||
make.bottom.equalTo(self).offset(-8);
|
||||
}];
|
||||
[self.rightPlusButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.rightCard.mas_bottom).offset(12);
|
||||
make.centerX.equalTo(self.rightCard);
|
||||
make.width.height.equalTo(self.plusButton);
|
||||
make.bottom.equalTo(self).offset(-8);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configWithItems:(NSArray<NSDictionary *> *)items {
|
||||
@@ -214,4 +233,30 @@
|
||||
return _plusButton;
|
||||
}
|
||||
|
||||
- (UIButton *)leftPlusButton {
|
||||
if (!_leftPlusButton) {
|
||||
_leftPlusButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_leftPlusButton setTitle:@"+" forState:UIControlStateNormal];
|
||||
[_leftPlusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
|
||||
_leftPlusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_leftPlusButton.layer.cornerRadius = 14.0;
|
||||
_leftPlusButton.layer.masksToBounds = YES;
|
||||
_leftPlusButton.backgroundColor = [[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] colorWithAlphaComponent:0.15];
|
||||
}
|
||||
return _leftPlusButton;
|
||||
}
|
||||
|
||||
- (UIButton *)rightPlusButton {
|
||||
if (!_rightPlusButton) {
|
||||
_rightPlusButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_rightPlusButton setTitle:@"+" forState:UIControlStateNormal];
|
||||
[_rightPlusButton setTitleColor:[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] forState:UIControlStateNormal];
|
||||
_rightPlusButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_rightPlusButton.layer.cornerRadius = 14.0;
|
||||
_rightPlusButton.layer.masksToBounds = YES;
|
||||
_rightPlusButton.backgroundColor = [[UIColor colorWithRed:0.20 green:0.65 blue:0.50 alpha:1.0] colorWithAlphaComponent:0.15];
|
||||
}
|
||||
return _rightPlusButton;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user