SwiftUI Webview 全屏问题
SwiftUI Webview fullscreen issue
我正在尝试使 WebView 适合屏幕,但我不能,我试过那样
import SwiftUI
extension View {
func toAnyView() -> AnyView{
AnyView(self)
}
}
struct ContentView: View {
@State private var showLoding: Bool = false
@State private var scrollViewContentOffset: CGFloat = .zero
var body: some View {
ZStack{
WebView(url: URL(string: "http://localhost:3000")!, showLoding: $showLoding)
.overlay(showLoding ? ProgressView("Loding...").toAnyView(): EmptyView().toAnyView())
.ignoresSafeArea()
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
但这就是结果
Photo
我无法使堆栈上升到状态栏下方
尝试在帧后使用“.ignoresSafeArea()”
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
.ignoresSafeArea()
我正在尝试使 WebView 适合屏幕,但我不能,我试过那样
import SwiftUI
extension View {
func toAnyView() -> AnyView{
AnyView(self)
}
}
struct ContentView: View {
@State private var showLoding: Bool = false
@State private var scrollViewContentOffset: CGFloat = .zero
var body: some View {
ZStack{
WebView(url: URL(string: "http://localhost:3000")!, showLoding: $showLoding)
.overlay(showLoding ? ProgressView("Loding...").toAnyView(): EmptyView().toAnyView())
.ignoresSafeArea()
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
但这就是结果 Photo 我无法使堆栈上升到状态栏下方
尝试在帧后使用“.ignoresSafeArea()”
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
.ignoresSafeArea()