Created
March 23, 2024 03:37
-
-
Save amosgyamfi/8828f99b3d2ad1fb854efb8e64840c55 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: 1, z: 1)) | |
.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