如何摆脱UIWebView上的状态栏背景? [英] How to get rid of the status bar background on the UIWebView?

查看:537
本文介绍了如何摆脱UIWebView上的状态栏背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从iOS 11开始,当 UIWebView 全屏时,状态栏上会出现一个假背景,其颜色与 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?

即使添加 IUWebView 到故事板并使其全屏显示将显示状态栏背景

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

我一直在尝试编辑UIWebView的大小和一些其他属性,但没有一个工作,但它肯定来自UIWebView。
还尝试查看所有子视图及其大小并没有看到任何奇怪的内容。

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.

附上截图,看到灰色的状态栏,它消失了滚动时,如果 UIWebView 未超出屏幕的那一部分,则不会出现。
我希望它在第二个屏幕截图中,只删除假背景,而不是状态栏。

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.


推荐答案

这是因为 UIScrollView 调整内容插入的新行为,包括安全区域插入,如状态栏。

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

要修复它,只需将其设置为 UIScrollViewContentInsetAdjustmentNever

To fix it, just set it to UIScrollViewContentInsetAdjustmentNever

[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];

从iOS 11 Beta 4开始,你可以将它添加到你的视口中,同时删除假状态栏

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

viewport-fit = cover

这篇关于如何摆脱UIWebView上的状态栏背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆