Reputation:
How to respond to view lifecycle events in SwiftUI?
onAppear()
onDisappear()
XCode Version: 12.0
Upvotes: 0
Views: 207
Reputation: 31
Like this way :
VStack {
Text("Hello World")
}.onAppear {
print("ContentView appeared!")
}.onDisappear {
print("ContentView disappeared!")
}
Upvotes: 3