@@ -536,6 +536,7 @@ - (void)viewDidLayoutSubviews {
536
536
BOOL hasMessage = (self.messageLabel .text .length > 0 && !self.messageLabel .hidden );
537
537
BOOL hasTextField = self.alertTextFields .count > 0 ;
538
538
BOOL hasCustomView = !!_customView;
539
+ BOOL shouldShowSeparatorAtTopOfButtonAtFirstLine = hasTitle || hasMessage || hasCustomView;
539
540
CGFloat contentOriginY = 0 ;
540
541
541
542
self.maskView .frame = self.view .bounds ;
@@ -606,16 +607,21 @@ - (void)viewDidLayoutSubviews {
606
607
// 对齐系统,先 add 的在右边,后 add 的在左边
607
608
QMUIAlertAction *leftAction = newOrderActions[1 ];
608
609
leftAction.button .frame = CGRectMake (0 , contentOriginY, CGRectGetWidth (self.buttonScrollView .bounds ) / 2 , self.alertButtonHeight );
609
- leftAction.button .qmui_borderPosition = QMUIViewBorderPositionTop| QMUIViewBorderPositionRight;
610
+ leftAction.button .qmui_borderPosition = QMUIViewBorderPositionRight;
610
611
QMUIAlertAction *rightAction = newOrderActions[0 ];
611
612
rightAction.button .frame = CGRectMake (CGRectGetMaxX (leftAction.button .frame ), contentOriginY, CGRectGetWidth (self.buttonScrollView .bounds ) / 2 , self.alertButtonHeight );
612
- rightAction.button .qmui_borderPosition = QMUIViewBorderPositionTop;
613
+ if (shouldShowSeparatorAtTopOfButtonAtFirstLine) {
614
+ leftAction.button .qmui_borderPosition |= QMUIViewBorderPositionTop;
615
+ rightAction.button .qmui_borderPosition = QMUIViewBorderPositionTop;
616
+ }
613
617
contentOriginY = CGRectGetMaxY (leftAction.button .frame );
614
618
} else {
615
619
for (int i = 0 ; i < newOrderActions.count ; i++) {
616
620
QMUIAlertAction *action = newOrderActions[i];
617
621
action.button .frame = CGRectMake (0 , contentOriginY, CGRectGetWidth (self.containerView .bounds ), self.alertButtonHeight );
618
- action.button .qmui_borderPosition = QMUIViewBorderPositionTop;
622
+ if (i > 0 || shouldShowSeparatorAtTopOfButtonAtFirstLine) {
623
+ action.button .qmui_borderPosition = QMUIViewBorderPositionTop;
624
+ }
619
625
contentOriginY = CGRectGetMaxY (action.button .frame );
620
626
}
621
627
}
@@ -717,17 +723,25 @@ - (void)viewDidLayoutSubviews {
717
723
if (action.style == QMUIAlertActionStyleCancel && i == newOrderActions.count - 1 ) {
718
724
continue ;
719
725
} else {
726
+ BOOL isFirstLine = floor (i / columnCount) == 0 ;
727
+ BOOL isLastColumn = fmod (i + 1 , columnCount) == 0 ;
728
+ BOOL shouldShowSeparatorAtTop = !isFirstLine || shouldShowSeparatorAtTopOfButtonAtFirstLine;
729
+ BOOL shouldShowSeparatorAtRight = !isLastColumn;// 单列时全都不用显示右分隔线,多列时最后一列不用显示右分隔线
720
730
action.button .frame = CGRectMake (alertActionsLayoutX, alertActionsLayoutY, alertActionsWidth, self.sheetButtonHeight );
721
- if (fmodf (i + 1 , columnCount) == 0 ) {
722
- action.button .qmui_borderPosition = QMUIViewBorderPositionTop;
731
+ if (isLastColumn) {
723
732
alertActionsLayoutX = 0 ;
724
733
alertActionsLayoutY = CGRectGetMaxY (action.button .frame );
725
734
} else {
726
- action.button .qmui_borderPosition = QMUIViewBorderPositionTop|QMUIViewBorderPositionRight;
727
735
alertActionsLayoutX += alertActionsWidth;
728
736
}
729
-
730
737
contentOriginY = MAX (contentOriginY, CGRectGetMaxY (action.button .frame ));
738
+
739
+ if (shouldShowSeparatorAtTop) {
740
+ action.button .qmui_borderPosition |= QMUIViewBorderPositionTop;
741
+ }
742
+ if (shouldShowSeparatorAtRight) {
743
+ action.button .qmui_borderPosition |= QMUIViewBorderPositionRight;
744
+ }
731
745
}
732
746
}
733
747
}
0 commit comments