Back to Library
Bank Card Flip

Hover to play

Bank Card Flip

by Luiz Mello

@luizmellodev
cardanimationui

Description

A credit card component that flips in 3D on tap to reveal the back side with smooth perspective and polished banking visuals.

SwiftUI Code

4 files • Scroll to see all →
//
// A credit card that flips in 3D on tap, revealing the back (CVV side).
// Uses rotation3DEffect with a FlipModifier that auto-hides each face
// at the 90° midpoint for a seamless two-sided effect.

struct BankCardFlip: View {
    @State private var flipped = false

    var body: some View {
        ZStack {
            CardFace()
                .modifier(FlipModifier(angle: flipped ? 180 : 0))

            CardBack()
                .modifier(FlipModifier(angle: flipped ? 0 : -180))
        }
        .animation(.spring(response: 0.65, dampingFraction: 0.78), value: flipped)
        .onTapGesture { flipped.toggle() }
    }
}
Viewing: BankCardFlip.swift1 of 4