ContentView.swift
struct ContentView: View {
var body: some View {
VStack{
NavigationLink(destination: SecondView()){
Text("Go to second view")
}
}
}
}
SecondView.swift
struct SecondView: View {
@State var showAlert = true
var body: some View {
// i want to show alert when navigate to this view
VStack{
Text("Second View")
.alert(isPresented: $showAlert) {
Alert(title: Text("You are in second view"))
}
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: