I have a menu of NavigationLinks (with images) that animate onto the screen from the bottom onAppear. Navigation works as expected when tapped, the links move off to the left as the destination view moves in from the right.
I would like the NavigationLinks to animate off the screen to the top before the destination view moves in. Is this possible with a NavigationView?
***** Edited *****
OK, same question with Buttons instead of NavigationLinks:
import SwiftUI
struct ContentView: View {
@State private var moving = false
@State private var showFirstView = false
var body: some View {
NavigationStack{
VStack{
Image("DogPhone")
.resizable()
.scaledToFit()
.cornerRadius(50.0)
.edgesIgnoringSafeArea(.all)
Spacer()
}
Button (action: { showFirstView = true }, label: {
Image("marker")
.resizable()
.frame(width: 80, height: 80)
.transition(.move(edge: .bottom))
.navigationDestination(isPresented:
$showFirstView) {
firstView()}
})
.offset(CGSize(width: -100.0, height: 10.0))
.offset(y: moving ? -100 : 400)
.animation(.interpolatingSpring(stiffness: 100,
damping: 8), value: moving)
//******* END BUTTON ONE ********
}
}
.onAppear{
moving.toggle()
}
.onDisappear{
moving.toggle()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.preferredColorScheme(.dark)
}
}