Skip to content

Commit

Permalink
Top notch view fix
Browse files Browse the repository at this point in the history
  • Loading branch information
expertanswerz authored and ChanchleshSuryawanshi committed Apr 9, 2020
1 parent 81aa8ba commit 1f182ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/ios/CDVInAppBrowserNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ - (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))com
- (void) viewDidLoad {

CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
statusBarFrame.size.height = STATUSBAR_HEIGHT;
//statusBarFrame.size.height = STATUSBAR_HEIGHT;
bool hasTopNotch = NO;
if (@available(iOS 11.0, *)) {
hasTopNotch = [[[UIApplication sharedApplication] delegate] window].safeAreaInsets.top > 20.0;
}
if(hasTopNotch){
statusBarFrame.size.height = [UIApplication sharedApplication].statusBarFrame.size.height;
} else {
statusBarFrame.size.height = STATUSBAR_HEIGHT;
}
// simplified from: http://stackoverflow.com/a/25669695/219684

UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:statusBarFrame];
Expand Down
19 changes: 17 additions & 2 deletions src/ios/CDVWKInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -1121,8 +1121,23 @@ - (void)viewWillAppear:(BOOL)animated
if (IsAtLeastiOSVersion(@"7.0") && !viewRenderedAtLeastOnce) {
viewRenderedAtLeastOnce = TRUE;
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = STATUSBAR_HEIGHT;
viewBounds.size.height = viewBounds.size.height - STATUSBAR_HEIGHT;
// viewBounds.origin.y = STATUSBAR_HEIGHT;
// viewBounds.size.height = viewBounds.size.height - STATUSBAR_HEIGHT;


bool hasTopNotch = NO;
if (@available(iOS 11.0, *)) {
hasTopNotch = [[[UIApplication sharedApplication] delegate] window].safeAreaInsets.top > 20.0;
}
if(hasTopNotch){
viewBounds.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
viewBounds.size.height = viewBounds.size.height - [UIApplication sharedApplication].statusBarFrame.size.height;
} else {
viewBounds.origin.y = STATUSBAR_HEIGHT;
viewBounds.size.height = viewBounds.size.height - STATUSBAR_HEIGHT;
}


self.webView.frame = viewBounds;
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
}
Expand Down

0 comments on commit 1f182ef

Please sign in to comment.