user14892208
user14892208

Reputation:

How to respond to view lifecycle events in SwiftUI?

How to respond to view lifecycle events in SwiftUI?

onAppear()
onDisappear()

XCode Version: 12.0

Upvotes: 0

Views: 207

Answers (1)

babou
babou

Reputation: 31

Like this way :

VStack {
   Text("Hello World") 
}.onAppear {
    print("ContentView appeared!")
}.onDisappear {
    print("ContentView disappeared!")
}

Upvotes: 3

Related Questions