A view that displays some web content.
Connect a ``WebView`` with a ``WebPage`` to fully control the browsing experience, including essential functionality such as loading a URL.
Any updates to the webpage propagate the information to the view.
Create a new WebView with the specified URL.
For example, you can create a WebView that displays one of two URLs depending on the state of a toggle:
```swift
struct URLView: View {
@State private var url: URL? = nil
@State private var toggle = false
var body: some View {
VStack {
Button("Toggle") {
toggle.toggle()
}
WebView(url: url)
}
.onChange(of: toggle, initial: true) {
url = toggle ? URL(string: "https://www.webkit.org") : URL(string: "https://www.apple.com")
}
}
}
```
- Parameter url: The URL to display in the view. If this value is non-nil or changes to become a non-nil value, the new URL is loaded into the view.
Create a new WebView.
- Parameter page: The ``WebPage`` that should be associated with this ``WebView``. It is a programming error to create multiple ``WebView``s with the same ``WebPage``.
Skipped declarations
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
WebView.body
This protocol needs associated types that cannot yet cross the bridge.