diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index eb21d15..c23a8eb 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -105,8 +105,8 @@ -(void)statusBarDidChangeFrame:(NSNotification*)notification //add a small delay ( 0.1 seconds ) or statusbar size will be wrong __weak CDVStatusBar* weakSelf = self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [weakSelf resizeStatusBarBackgroundView]; [weakSelf resizeWebView]; + [weakSelf resizeStatusBarBackgroundView]; }); } @@ -210,6 +210,8 @@ - (void) initializeStatusBarBackgroundView statusBarFrame.origin.y = 0; } + statusBarFrame.size.height = self.webView.frame.origin.y; //frameYStart + _statusBarBackgroundView = [[UIView alloc] initWithFrame:statusBarFrame]; _statusBarBackgroundView.backgroundColor = _statusBarBackgroundColor; _statusBarBackgroundView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin); @@ -421,6 +423,7 @@ - (void) show:(CDVInvokedUrlCommand*)command -(void)resizeStatusBarBackgroundView { CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; + statusBarFrame.size.height = self.webView.frame.origin.y; // Set the height to the current webView origin in case it has been changed after resizing CGRect sbBgFrame = _statusBarBackgroundView.frame; sbBgFrame.size = statusBarFrame.size; _statusBarBackgroundView.frame = sbBgFrame; @@ -440,11 +443,11 @@ -(void)resizeWebView CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame; CGRect frame = self.webView.frame; CGFloat height = statusBarFrame.size.height; + float safeAreaTop = self.webView.safeAreaInsets.top; if (!self.statusBarOverlaysWebView) { - frame.origin.y = height; + frame.origin.y = height >= safeAreaTop || height == 0 ? height : safeAreaTop; } else { - float safeAreaTop = self.webView.safeAreaInsets.top; if (height >= safeAreaTop && safeAreaTop >0) { // Sometimes when in-call/recording/hotspot larger status bar is present, the safeAreaTop is 40 but we want frame.origin.y to be 20 frame.origin.y = safeAreaTop == 40 ? 20 : height - safeAreaTop;