Created
March 17, 2024 09:44
-
-
Save amosgyamfi/a5c6764a149d67538403c48729b4d663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DefaultAnimationAnimationModifier.swift | |
// OpenSwiftUIAnimations | |
import SwiftUI | |
struct DefaultAnimationAnimationModifier: View { | |
let letters = Array("Hello") | |
@State private var flipAngle = Double.zero | |
var body: some View { | |
VStack(spacing: 32) { | |
HStack(spacing: 0) { | |
ForEach(0..<letters.count, id: \.self) { flip in | |
Text(String(letters[flip])) | |
.font(.largeTitle) | |
.rotation3DEffect(.degrees(flipAngle), axis: (x: 1, y: 0, z: 0)) | |
.animation(.default.delay(Double(flip) * 0.1), value: flipAngle) | |
} | |
} | |
Button { | |
flipAngle = (flipAngle == .zero) ? 360 : .zero | |
} label: { | |
Text("Flip") | |
} | |
} | |
} | |
} | |
#Preview { | |
DefaultAnimationAnimationModifier() | |
.preferredColorScheme(.dark) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment