struct CardView: View {
@State var isFaceUp = false
var body: some View {
ZStack {
let shape = RoundedRectangle(cornerRadius: 20)
if isFaceUp {
shape.fill().foregroundColor(.white)
shape.stroke(lineWidth: 3)
Text("😀").font(.system(size: 80))
} else {
shape.fill()
}
}
.rotation3DEffect(Angle(degrees: isFaceUp ? 180 : 0), axis: (x: 0, y: 1, z: 0))
.animation(.spring(), value: isFaceUp)
.onTapGesture {
isFaceUp.toggle()
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: