Created
November 29, 2022 15:19
-
-
Save gewill/b80bb49e4085a48813760b759e23c7f6 to your computer and use it in GitHub Desktop.
WebView for macOS in SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import WebKit | |
struct WebView: NSViewRepresentable { | |
typealias NSViewType = WKWebView | |
var html: String | |
func makeNSView(context: Context) -> WKWebView { | |
return WKWebView() | |
} | |
func updateNSView(_ nsView: WKWebView, context: Context) { | |
nsView.loadHTMLString(html, baseURL: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment