Skip to content

Commit f02659a

Browse files
committed
Merge pull request Sumi-Interactive#47 from peterwilli/master
Allowed to use 1 button per row even if the buttons count < 2 by overriding SIAlertViewButtonsListStyle
2 parents b9e9bf6 + ba484a8 commit f02659a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

SIAlertView/SIAlertView.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ typedef NS_ENUM(NSInteger, SIAlertViewBackgroundStyle) {
2424
SIAlertViewBackgroundStyleSolid,
2525
};
2626

27+
typedef NS_ENUM(NSInteger, SIAlertViewButtonsListStyle) {
28+
SIAlertViewButtonsListStyleNormal = 0,
29+
SIAlertViewButtonsListStyleRows
30+
};
31+
2732
typedef NS_ENUM(NSInteger, SIAlertViewTransitionStyle) {
2833
SIAlertViewTransitionStyleSlideFromBottom = 0,
2934
SIAlertViewTransitionStyleSlideFromTop,
@@ -42,6 +47,7 @@ typedef void(^SIAlertViewHandler)(SIAlertView *alertView);
4247

4348
@property (nonatomic, assign) SIAlertViewTransitionStyle transitionStyle; // default is SIAlertViewTransitionStyleSlideFromBottom
4449
@property (nonatomic, assign) SIAlertViewBackgroundStyle backgroundStyle; // default is SIAlertViewButtonTypeGradient
50+
@property (nonatomic, assign) SIAlertViewButtonsListStyle buttonsListStyle; // default is SIAlertViewButtonsListStyleNormal
4551

4652
@property (nonatomic, copy) SIAlertViewHandler willShowHandler;
4753
@property (nonatomic, copy) SIAlertViewHandler didShowHandler;

SIAlertView/SIAlertView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ - (void)validateLayout
676676
if (y > CONTENT_PADDING_TOP) {
677677
y += GAP;
678678
}
679-
if (self.items.count == 2) {
679+
if (self.items.count == 2 && self.buttonsListStyle == SIAlertViewButtonsListStyleNormal) {
680680
CGFloat width = (self.containerView.bounds.size.width - CONTENT_PADDING_LEFT * 2 - GAP) * 0.5;
681681
UIButton *button = self.buttons[0];
682682
button.frame = CGRectMake(CONTENT_PADDING_LEFT, y, width, BUTTON_HEIGHT);
@@ -715,7 +715,7 @@ - (CGFloat)preferredHeight
715715
if (height > CONTENT_PADDING_TOP) {
716716
height += GAP;
717717
}
718-
if (self.items.count <= 2) {
718+
if (self.items.count <= 2 && self.buttonsListStyle == SIAlertViewButtonsListStyleNormal) {
719719
height += BUTTON_HEIGHT;
720720
} else {
721721
height += (BUTTON_HEIGHT + GAP) * self.items.count - GAP;

0 commit comments

Comments
 (0)