我正在尝试在 SwiftUI 中链接两个动画。但是,按下按钮时第一个动画没有动画。我在这里找到了这种链接动画的方法:Chaining animations in SwiftUI
struct FancyButtonViewModel: View {
@State var movementY:CGFloat = 0
var body: some View {
VStack{
Text("")
.offset(y: movementY)
Button("Press Me"){
withAnimation(Animation.easeOut(duration: 0.5)) {
movementY = -150
}
withAnimation(Animation.easeIn(duration: 3).delay(0.5)) {
movementY = 0
}
}
}
}
}