Here i need help, i want to change webview by clicking a button in navigation bar item please help me, can be this possible... IN swiftui
Import Swiftui
var body: some View {
NavigationView {
VStack {
WebKit(request: URLRequest(url: URL(string : api + endpoint)!))
}.navigationBarTitle(Text(""), displayMode: .inline)
.navigationBarItems(leading: HStack{
Button(action:{}){
Image("test2")
.foregroundColor(Color.black)
};
};Button(action:{
}){
Image("test2")
.foregroundColor(Color.black)
.padding(.top, 5.0)
}},
trailing: HStack{ Button(action:{}){
Image("test2")
.foregroundColor(Color.black)
};
Button(action:{}){
Image("test2")
.foregroundColor(Color.black)
};
Button(action:{}){
Image("test2")
.foregroundColor(Color.black)
}
}
) }
};func onAppear(){
UINavigationBar.appearance().barTintColor = UIColor(red: 0, green: 100/255, blue: 205/255, alpha: 1)
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
}
}
struct WebKit: UIViewRepresentable{
let request: URLRequest
func makeUIView(context: UIViewRepresentableContext<WebKit>) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.load(request)
}
}