SwiftUIWKWebView

1.0.6

WKWebView as NSViewRepresentable for usage in macOS environment and UIViewRepresentable for UIKit
JakubMazur/SwiftUIWKWebView

What's New

1.0.6

2021-06-28T19:23:21Z

SwiftUIWKWebView

WKWebView as NSViewRepresentable for usage in macOS environment and UIViewRepresentable for UIKit

Usage

Without ViewModel

Loading a website inside a frame, navigation is possible inside a webpage, but there is no ObservedObject

struct MyWebView: View {
    var body: some View {
        SwiftUIWKWebView(viewModel: .init(urlString: "https://apple.com")!)
    }
}

With ViewModel

extend WebViewModel for more actions from WKNavigationDelegate

struct MyWebView: View {
    @ObservedObject var viewModel: WebViewModel
	
    var body: some View {
        SwiftUIWKWebView(viewModel: viewModel)
    }
}

struct MyWebView_Previews: PreviewProvider {
    static var previews: some View {
        MyWebView(viewModel: .init(urlString: "https://twitter.com/jkmazur")!)
    }
}

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Oct 21 2024 14:07:29 GMT-0900 (Hawaii-Aleutian Daylight Time)