Skip to content

Commit 215eedb

Browse files
authored
Using safe area insets on ios 11 and higher (#247)
1 parent ea34f3c commit 215eedb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Leanplum-SDK/Classes/LPMessageTemplates.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,13 @@ - (void)updatePopupLayout
961961
[context.actionName isEqualToString:LPMT_HTML_NAME]);
962962
BOOL isWeb = [context.actionName isEqualToString:LPMT_WEB_INTERSTITIAL_NAME] ||
963963
[context.actionName isEqualToString:LPMT_HTML_NAME];
964-
965-
CGFloat statusBarHeight = ([[UIApplication sharedApplication] isStatusBarHidden] || !fullscreen) ? 0
964+
965+
UIEdgeInsets safeAreaInsets = [self safeAreaInsets];
966+
967+
CGFloat statusBarHeight = ([[UIApplication sharedApplication] isStatusBarHidden] || !fullscreen) ? safeAreaInsets.top
966968
: MIN([UIApplication sharedApplication].statusBarFrame.size.height,
967969
[UIApplication sharedApplication].statusBarFrame.size.width);
968-
970+
969971
UIInterfaceOrientation orientation;
970972
if (LP_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
971973
orientation = UIInterfaceOrientationPortrait;
@@ -1023,8 +1025,6 @@ - (void)updatePopupLayout
10231025
[self updateNonWebPopupLayout:statusBarHeight];
10241026
_overlayView.frame = CGRectMake(0, 0, screenWidth, screenHeight);
10251027
}
1026-
1027-
UIEdgeInsets safeAreaInsets = [self safeAreaInsets];
10281028
CGFloat leftSafeAreaX = safeAreaInsets.left;
10291029
CGFloat dismissButtonX = screenWidth - _dismissButton.frame.size.width - LPMT_ACCEPT_BUTTON_MARGIN / 2;
10301030
CGFloat dismissButtonY = statusBarHeight + LPMT_ACCEPT_BUTTON_MARGIN / 2;
@@ -1242,7 +1242,9 @@ -(UIEdgeInsets)safeAreaInsets
12421242
{
12431243
UIEdgeInsets insets = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
12441244
if (@available(iOS 11.0, *)) {
1245-
insets = [UIApplication sharedApplication].keyWindow.safeAreaInsets;
1245+
insets = [UIApplication sharedApplication].keyWindow.safeAreaInsets;
1246+
} else {
1247+
insets.top = [[UIApplication sharedApplication] isStatusBarHidden] ? 0 : 20.0;
12461248
}
12471249
return insets;
12481250
}

0 commit comments

Comments
 (0)