Skip to content

Commit 33f3541

Browse files
committed
make sure customized alert shows below system's alert
1 parent 0ef3936 commit 33f3541

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

SIAlertView/SIAlertView.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#define BUTTON_HEIGHT 44
2727
#define CONTAINER_WIDTH 300
2828

29+
const UIWindowLevel UIWindowLevelSIAlert = 1999.0; // don't overlap system's alert
30+
const UIWindowLevel UIWindowLevelSIAlertBackground = 1998.0; // below the alert window
31+
2932
@class SIAlertBackgroundWindow;
3033

3134
static NSMutableArray *__si_alert_queue;
@@ -82,7 +85,7 @@ - (id)initWithFrame:(CGRect)frame andStyle:(SIAlertViewBackgroundStyle)style
8285
self.style = style;
8386
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
8487
self.opaque = NO;
85-
self.windowLevel = UIWindowLevelAlert;
88+
self.windowLevel = UIWindowLevelSIAlertBackground;
8689
}
8790
return self;
8891
}
@@ -324,7 +327,7 @@ - (void)show
324327
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
325328
window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
326329
window.opaque = NO;
327-
window.windowLevel = UIWindowLevelAlert + 1.0;
330+
window.windowLevel = UIWindowLevelSIAlert;
328331
window.rootViewController = viewController;
329332
self.alertWindow = window;
330333
}

0 commit comments

Comments
 (0)