Skip to content

Commit 8844af3

Browse files
committed
UIApplication statusBarFrame deprecated in iOS 13
1 parent 2a78215 commit 8844af3

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

LTHPasscodeViewController/LTHPasscodeViewController.m

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,12 +1927,33 @@ - (void)enablePasscodeWhenApplicationEntersBackground {
19271927

19281928
+ (CGFloat)getStatusBarHeight {
19291929
UIInterfaceOrientation orientation = [LTHPasscodeViewController currentOrientation];
1930-
if (UIInterfaceOrientationIsLandscape(orientation)) {
1931-
return [UIApplication sharedApplication].statusBarFrame.size.width;
1930+
1931+
// statusBarFrame is deprecated in iOS 13 and windowScene isn't available before iOS 13
1932+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1933+
if (@available(iOS 13.0, *))
1934+
{
1935+
if (UIInterfaceOrientationIsLandscape(orientation)) {
1936+
return LTHMainWindow.windowScene.statusBarManager.statusBarFrame.size.width;
1937+
}
1938+
else {
1939+
return LTHMainWindow.windowScene.statusBarManager.statusBarFrame.size.height;
1940+
}
19321941
}
1933-
else {
1934-
return [UIApplication sharedApplication].statusBarFrame.size.height;
1942+
else
1943+
{
1944+
#pragma clang diagnostic push
1945+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1946+
#endif
1947+
if (UIInterfaceOrientationIsLandscape(orientation)) {
1948+
return [UIApplication sharedApplication].statusBarFrame.size.width;
1949+
}
1950+
else {
1951+
return [UIApplication sharedApplication].statusBarFrame.size.height;
1952+
}
1953+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
1954+
#pragma clang diagnostic pop
19351955
}
1956+
#endif
19361957
}
19371958

19381959

0 commit comments

Comments
 (0)