问题描述
问题是关于在全屏模式下使用 webview 使顶部状态栏不透明
let url = URL(string: "https://www.stubfee.com/account/")!
let jRequest = URLRequest(url: url)
webView.scrollView.showsHorizontalScrollIndicator = false
webView.scrollView.showsverticalScrollIndicator = false
webView.load(jRequest)
navigationController?.isToolbarHidden = true
navigationController?.isNavigationBarHidden = true
我试过了
<Meta content="viewport-fit=cover" >
但这不是我想要的,我希望状态栏保持不变,但不透明,只是不透明...
我也在 main.storyboard 中尝试过
我试过 navigationController?.navigationBar.isTranslucent = false
也不起作用 :(
我还能尝试什么?
解决方法
我找到了一个两面的解决方案。
第一面:info.plist https://sarunw.com/posts/how-to-set-status-bar-style/
// Add View controller-based status bar appearance key (UIViewControllerBasedStatusBarAppearance) and set value to No (false).
// Add Status bar style key (UIStatusBarStyle) and set value to Light Content (UIStatusBarStyleLightContent).
SIDE 2 : html : 我添加了一个具有良好高度和位置固定和顶部的 div -
<div style="height:169;top:-111;background:black;width:100%;position:fixed;" ></div>
就是这样,当内容滚动时,这个 div 将其全部隐藏;)