From b7079e3b3b6d32a336a17c1787af2a91f2d9a6bb Mon Sep 17 00:00:00 2001 From: Nashuim Date: Tue, 10 Dec 2024 11:41:33 +0000 Subject: [PATCH 1/2] Handle frame origin when status bar isn't overlaying the web view --- src/ios/CDVStatusBar.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index eb21d15..9d8acfa 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -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); @@ -440,11 +442,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 : 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; From 41a77f532bc21e009cd68b87a4131c2841265491 Mon Sep 17 00:00:00 2001 From: Nashuim Date: Fri, 13 Dec 2024 10:18:47 +0000 Subject: [PATCH 2/2] Handle resize issues --- src/ios/CDVStatusBar.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index 9d8acfa..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]; }); } @@ -423,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; @@ -445,7 +446,7 @@ -(void)resizeWebView float safeAreaTop = self.webView.safeAreaInsets.top; if (!self.statusBarOverlaysWebView) { - frame.origin.y = height >= safeAreaTop ? height : safeAreaTop; + frame.origin.y = height >= safeAreaTop || height == 0 ? height : safeAreaTop; } else { 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