这是我的代码:
import SwiftUI
@main
struct BouncingApp: App {
var body: some Scene {
WindowGroup {
BounceAble()
}
}
}
struct BounceAble: View {
@State var bounce: Bool = false
var body: some View {
VStack(alignment: .center) {
Button("Bounce") {
withAnimation(.easeOut) {
bounce.toggle()
}
}
}
.overlay {
if bounce {
Circle()
.frame(width: 200, height: 200)
.transition(.slide)
.transition(.scale)
.onTapGesture {
withAnimation(.easeIn) {
bounce.toggle()
}
}
}
}
}
}
问题是我希望我的圆圈在同时增长的同时滑动.我认为一次添加两个过渡可以完成这项工作,但事实并非如此.我的代码有逻辑问题吗?非常感谢你.