Skip to content

Instantly share code, notes, and snippets.

@ChrisMash
Last active February 16, 2022 19:44
Show Gist options
  • Select an option

  • Save ChrisMash/4faa01218443edddb4fd50805091c58c to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMash/4faa01218443edddb4fd50805091c58c to your computer and use it in GitHub Desktop.
Snapshot of DeckView from https://github.com/ChrisMash/SwiftUI-Playing-Cards for my blog
struct DeckView: View {
@ObservedObject var deck: Hand
let namespace: Namespace.ID
var body: some View {
ZStack {
// Just need to draw the last two so that the transition of card
// from the hand back to the deck results in the old top card being
// rendered as the new top card animates in
ForEach(deck.cards.suffix(2)) {
CardView(card: $0, namespace: namespace)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment