我有两个视图:一个图像和一个形状,填充图像.一旦我翻转了图像应该显示的形状.以下是我的代码;
struct DogCard: View {
@State var animationAmount = 0.0
@State var isFaceUp: Bool = false
var card: MemoryGame.Card
var body: some View {
ZStack{
let shape = RoundedRectangle(cornerRadius: 10)
if card.isFaceUp {
shape.stroke(lineWidth: 3).foregroundColor(.blue)
Image(card.content).resizable().scaledToFit().padding()
}
else {
shape.fill().foregroundColor(.blue)
}
}
.rotation3DEffect(.degrees(animationAmount), axis: (x: 0, y: 1, z: 0))
.onTapGesture {
withAnimation {
animationAmount += 180
isFaceUp.toggle()
}
}
}
}
I am trying to have the image show up once the shape is tapped on and made to flip.
^当您点击形状时,它会翻转(不显示图像-错误)