Created
October 24, 2024 01:44
-
-
Save takoikatakotako/1fb32da9087ad60989903dffb4b79dd1 to your computer and use it in GitHub Desktop.
NavigationLinkを使用せずにプッシュ遷移する(.navigationDestination)
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
| import SwiftUI | |
| struct ContentView: View { | |
| @State var isActive: Bool = false | |
| var body: some View { | |
| NavigationStack { | |
| VStack { | |
| Button(action: { | |
| isActive = true | |
| }) { | |
| Text("Tap Me!!") | |
| } | |
| } | |
| .navigationDestination(isPresented: $isActive) { | |
| Text("SecondView") | |
| } | |
| } | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment