swiftui button navigation link code example
Example 1: swiftui navigation link with button
Button(action: {
}) {
NavigationLink(destination: SecondView()) {
Text("click")
}
}
Example 2: swiftui navigation button
ForEach (self.drinks, id: \.name)
{
drink in
//detail: The SwiftUI view you want to go to
NavigationLink(destination: DrinkDetail(drink: drink))
{
//the button/image you click on to go to that view
DrinkItem(drink: drink)
.frame(width: 300)
.padding(.trailing, 30)
}
}