I’m trying to fix this problem. I have some code where I’m trying to do a transition with animation and want to slide from card to card but I don’t get any sliding transition it just pop up. It don’t slide.
@State var dealtCard = false
var body: some View {
ZStack {
Image("white-background")
.resizable()
.ignoresSafeArea()
VStack {
HStack {
Spacer()
if dealtCard {
Image(cardDealt)
.resizable()
.cornerRadius(15)
.aspectRatio(contentMode: .fill)
.transition(.slide)
}
Spacer()
}.shadow(radius: 4)
Spacer()
HStack {
Button {
//Action for button
deal()
} label:{
// How the button look
Text("Draw")
.foregroundColor(.white)
.padding()
.background(.black)
.cornerRadius(15.0)
.font(.system(size:25))
.fontWeight(.bold)
}
Button {
//Action for button
dismiss()
} label:{
// How the button look
Text("End Game")
.foregroundColor(.white)
.padding()
.background(.black)
.cornerRadius(15.0)
.font(.system(size:25))
.fontWeight(.bold)
}
}.buttonBorderShape(.capsule)
}
}
}
func deal() {
let cpuCardValue = Int.random(in:1...20)
cardDealt = "card" + String(cpuCardValue)
withAnimation(.easeOut) {
dealtCard = true
}
}
}