Skip to content

Commit

Permalink
(ios) fix status bar for phones with top notch
Browse files Browse the repository at this point in the history
  • Loading branch information
micbis committed Jan 23, 2020
1 parent 09ad59f commit 10bda9e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ios/CDVInAppBrowserNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Licensed to the Apache Software Foundation (ASF) under one

@implementation CDVInAppBrowserNavigationController : UINavigationController

- (BOOL)hasTopNotch {
if (@available(iOS 11.0, *)) {
return [[[UIApplication sharedApplication] delegate] window].safeAreaInsets.top > 20.0;
}

return NO;
}

- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
if ( self.presentedViewController) {
[super dismissViewControllerAnimated:flag completion:completion];
Expand All @@ -32,7 +40,11 @@ - (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))com
- (void) viewDidLoad {

CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
statusBarFrame.size.height = STATUSBAR_HEIGHT;
if ([self hasTopNotch]) {
statusBarFrame.size.height = 44;
} else {
statusBarFrame.size.height = STATUSBAR_HEIGHT;
}
// simplified from: http://stackoverflow.com/a/25669695/219684

UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:statusBarFrame];
Expand Down

0 comments on commit 10bda9e

Please sign in to comment.