I’m trying to build a NavigationStack that has Buttons instead of links.
While I know how to make Text look like a Button, am unsure as to how to give it the changing appearance look of a Button when it is pressed.
The code below is using two @State vars so that I can reduce the fake Button’s size. But with all the different .onTapX permutations, I can not find the correct one to modify the @State vars when the button is being pressed down.
Thank you
import SwiftUI
struct MainMenuWithStack: View {
@State var butW : CGFloat = 150
@State var butH : CGFloat = 75
@State var curTG = "--"
var body: some View {
NavigationStack{
VStack(spacing: 5) {
NavigationLink(destination: HomePage()){
Text("Home")
.foregroundStyle(.white)
.font(.title)
.frame(width: butW, height: butH)
.background(.blue)
.cornerRadius(10)
}
}
}
}
}
#Preview {
MainMenuWithStack()
}