需要删除白屏幕,然后在iOS中加载网页视图,尝试不透明的网页视图。即使在添加了Splash屏幕和启动屏幕之后,在加载Webview之前,我仍然会得到白色的飞溅。
import UIKit
import WebKit
class HomeViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
webView.isOpaque = false
}
override func viewDidLoad() {
super.viewDidLoad()
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.translatesAutoresizingMaskIntoConstraints = false
let myURL = URL(string:"https://google.com")
let myRequest = URLRequest(url: myURL!)
view.addSubview(webView)
webView.load(myRequest)
NSLayoutConstraint.activate([
webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
webView.leftAnchor.constraint(equalTo: view.leftAnchor),
webView.rightAnchor.constraint(equalTo: view.rightAnchor)
])}
}发布于 2022-01-05 05:25:13
//Xcode13 13
webView.isOpaque = false;
webView.backgroundColor = UIColor.clear;发布于 2021-12-31 08:46:10
您试过删除webView的背景色吗?
webView.backgroundColor = .clear发布于 2021-12-31 10:46:54
你试过吗
self.webView.scrollView.backgroundColor = .clearhttps://stackoverflow.com/questions/70540354
复制相似问题