Created
June 23, 2020 01:33
-
-
Save aheze/b98f9e5f6a086abcd62832f0ed95edca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @main | |
| struct HelloWorldApp: App { | |
| @Environment(\.scenePhase) private var scenePhase | |
| var body: some Scene { | |
| WindowGroup { | |
| ContentView() | |
| } | |
| .onChange(of: scenePhase) { (newScenePhase) in | |
| switch newScenePhase { | |
| case .active: | |
| print("scene is now active!") | |
| case .inactive: | |
| print("scene is now inactive!") | |
| case .background: | |
| print("scene is now in the background!") | |
| @unknown default: | |
| print("Apple must have added something new!") | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment