button navigation link swiftui code example
Example 1: swiftui navigation link with button
Button(action: {
}) {
NavigationLink(destination: SecondView()) {
Text("click")
}
}
Example 2: add navigation bar button swiftui
.navigationBarItems(
leading: Button(action: {
}, label: { Text("Button") }),
trailing: Button(action: {
}, label: { Image("Icon") })
)
Example 3: swiftui navigation button
ForEach (self.drinks, id: \.name)
{
drink in
NavigationLink(destination: DrinkDetail(drink: drink))
{
DrinkItem(drink: drink)
.frame(width: 300)
.padding(.trailing, 30)
}
}