-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi_WebView.swift
More file actions
41 lines (34 loc) · 975 Bytes
/
api_WebView.swift
File metadata and controls
41 lines (34 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// api_WebView.swift
// HelloSwift
//
// Created by 1 on 8/21/22.
//
import SwiftUI
import WebKit
fileprivate struct WebView: UIViewRepresentable {
var url: URL
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
let request = URLRequest(url: url)
uiView.load(request)
uiView.allowsBackForwardNavigationGestures = true
}
}
struct api_WebView: View {
@State var urlSite:String = "https://www.baidu.com"
var body: some View {
WebView(url: URL(string: self.urlSite)!)
.edgesIgnoringSafeArea([.bottom])
.navigationTitle("WebView")
.navigationBarTitleDisplayMode(.inline)
.modifier(navBarViewCodeAndDocs(pageType: "API",pageID: "WebView"))
}
}
struct api_WebView_Previews: PreviewProvider {
static var previews: some View {
api_WebView()
}
}