Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created October 24, 2024 01:44
Show Gist options
  • Select an option

  • Save takoikatakotako/1fb32da9087ad60989903dffb4b79dd1 to your computer and use it in GitHub Desktop.

Select an option

Save takoikatakotako/1fb32da9087ad60989903dffb4b79dd1 to your computer and use it in GitHub Desktop.
NavigationLinkを使用せずにプッシュ遷移する(.navigationDestination)
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