2

New to iOS development.

ContentView.swift:

struct ContentView: View {
    var body: some View {
         WebView(url: "https://www.stackoverflow.com")
    }
}

WebView.swift:

struct WebView: UIViewRepresentable {
    
    var url: String
    
    func makeUIView(context: Context) -> WKWebView {
        guard let url = URL(string: self.url) else {
            return WKWebView();
        }
              
        let request = URLRequest(url: url)
        let wkWebView = WKWebView()
        wkWebView.load(request)
        wkWebView.allowsBackForwardNavigationGestures = true
        return wkWebView
    }
    
    func updateUIView(_ uiView: WKWebView, context: UIViewRepresentableContext<WebView>) {
      
    }
}

results in a white bar behind the home button indicator:

white bar

How can I make the webview fullscreen so that there is no more white bar behind the home button?

Hillcow
  • 890
  • 3
  • 19
  • 48

1 Answers1

7

You need to set bottom space of Your WebView not to Safe Area but to Superview Select View here

storyboard example

for SwiftUI version just do

struct ContentView: View {
    var body: some View {
         WebView(url: "https://www.stackoverflow.com")
         .edgesIgnoringSafeArea([.bottom])
    }
}
Kstin
  • 659
  • 1
  • 4
  • 18