@@ -536,6 +536,7 @@ - (void)viewDidLayoutSubviews {
536536 BOOL hasMessage = (self.messageLabel .text .length > 0 && !self.messageLabel .hidden );
537537 BOOL hasTextField = self.alertTextFields .count > 0 ;
538538 BOOL hasCustomView = !!_customView;
539+ BOOL shouldShowSeparatorAtTopOfButtonAtFirstLine = hasTitle || hasMessage || hasCustomView;
539540 CGFloat contentOriginY = 0 ;
540541
541542 self.maskView .frame = self.view .bounds ;
@@ -606,16 +607,21 @@ - (void)viewDidLayoutSubviews {
606607 // 对齐系统,先 add 的在右边,后 add 的在左边
607608 QMUIAlertAction *leftAction = newOrderActions[1 ];
608609 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;
610611 QMUIAlertAction *rightAction = newOrderActions[0 ];
611612 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+ }
613617 contentOriginY = CGRectGetMaxY (leftAction.button .frame );
614618 } else {
615619 for (int i = 0 ; i < newOrderActions.count ; i++) {
616620 QMUIAlertAction *action = newOrderActions[i];
617621 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+ }
619625 contentOriginY = CGRectGetMaxY (action.button .frame );
620626 }
621627 }
@@ -717,17 +723,25 @@ - (void)viewDidLayoutSubviews {
717723 if (action.style == QMUIAlertActionStyleCancel && i == newOrderActions.count - 1 ) {
718724 continue ;
719725 } 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;// 单列时全都不用显示右分隔线,多列时最后一列不用显示右分隔线
720730 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) {
723732 alertActionsLayoutX = 0 ;
724733 alertActionsLayoutY = CGRectGetMaxY (action.button .frame );
725734 } else {
726- action.button .qmui_borderPosition = QMUIViewBorderPositionTop|QMUIViewBorderPositionRight;
727735 alertActionsLayoutX += alertActionsWidth;
728736 }
729-
730737 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+ }
731745 }
732746 }
733747 }
0 commit comments