Search code examples
iosobjective-cswiftcordovauiwebview

How to get rid of the status bar background on the UIWebView?


Since iOS 11, when the UIWebView is full screen, a fake background appears on the status bar with the same color of the UIWebView background.

Anyone knows how to get rid of it?

Even adding the IUWebView to a storyboard and make it full screen will make the status bar background to appear

I've been trying to edit the size and some other properties of the UIWebView and none of them worked, but it's definitely something from the UIWebView. Also tried to see all the subviews and it's sizes and didn't see anything strange.

Attached a screenshot, see the grey "statusbar", it disappears when scrolling, and doesn't appear if the UIWebView is not over that part of the screen. I want it as on the second screenshot, only remove the fake background, not the status bar.

See the Screenshot enter image description here


Solution

  • This happens because of UIScrollView new behavior to adjust the content inset to include safe area insets like the status bar.

    To fix it, just set it to UIScrollViewContentInsetAdjustmentNever

    [self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
    

    Since iOS 11 Beta 4 you can add this to your viewport and will also remove the fake statusbar

    viewport-fit=cover