This commit is contained in:
2025-10-30 13:57:34 +08:00
parent 74476cd592
commit 783d088f22

View File

@@ -78,9 +78,8 @@
}]; }];
self.leftButtonsInternal = leftBtns.copy; self.leftButtonsInternal = leftBtns.copy;
// 3 // N
NSMutableArray<UIButton *> *rightBtns = [NSMutableArray arrayWithCapacity:3]; NSMutableArray<UIButton *> *rightBtns = [NSMutableArray arrayWithCapacity:3];
UIView *next = nil;
for (NSInteger i = 0; i < self.rightTitles.count; i++) { for (NSInteger i = 0; i < self.rightTitles.count; i++) {
UIButton *btn = [self buildButtonWithTitle:(i < self.rightTitles.count ? self.rightTitles[i] : [NSString stringWithFormat:@"R%ld", (long)i])]; UIButton *btn = [self buildButtonWithTitle:(i < self.rightTitles.count ? self.rightTitles[i] : [NSString stringWithFormat:@"R%ld", (long)i])];
btn.tag = 200 + i; btn.tag = 200 + i;
@@ -89,25 +88,27 @@
[rightBtns addObject:btn]; [rightBtns addObject:btn];
} }
// // 1/2/3...
UIButton *r0 = rightBtns.count > 0 ? rightBtns[0] : nil; UIView *prevRight = nil; //
UIButton *r1 = rightBtns.count > 1 ? rightBtns[1] : nil; for (NSInteger i = rightBtns.count - 1; i >= 0; i--) {
UIButton *r2 = rightBtns.count > 2 ? rightBtns[2] : nil; UIButton *btn = rightBtns[i];
if (r0 && r1 && r2) { [btn mas_makeConstraints:^(MASConstraintMaker *make) {
[r2 mas_makeConstraints:^(MASConstraintMaker *make) { if (!prevRight) {
//
make.right.equalTo(self.rightContainer.mas_right); make.right.equalTo(self.rightContainer.mas_right);
} else {
//
make.right.equalTo(prevRight.mas_left).offset(-8);
make.width.equalTo(prevRight);
}
make.top.bottom.equalTo(self.rightContainer); make.top.bottom.equalTo(self.rightContainer);
}]; }];
[r1 mas_makeConstraints:^(MASConstraintMaker *make) { prevRight = btn;
make.right.equalTo(r2.mas_left).offset(-8); }
make.top.bottom.equalTo(self.rightContainer); //
make.width.equalTo(r2); if (prevRight) {
}]; [prevRight mas_makeConstraints:^(MASConstraintMaker *make) {
[r0 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.greaterThanOrEqualTo(self.rightContainer.mas_left);
make.right.equalTo(r1.mas_left).offset(-8);
make.top.bottom.equalTo(self.rightContainer);
make.width.equalTo(r1);
make.left.greaterThanOrEqualTo(self.rightContainer.mas_left); //
}]; }];
} }