Created
March 23, 2024 03:32
-
-
Save amosgyamfi/e48227688a0d46dc7bbd3d780fe62e18 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
// | |
// DefaultAnimationWithAnimation.swift | |
// OpenSwiftUIAnimations | |
// | |
// Created by Amos Gyamfi on 16.3.2024. | |
// | |
import SwiftUI | |
struct DefaultAnimationWithAnimation: View { | |
@State private var flipAngle = Double.zero | |
var body: some View { | |
VStack(spacing: 32) { | |
Text("Hello") | |
.font(.largeTitle) | |
.rotation3DEffect ( | |
.degrees(flipAngle), | |
axis: (x: 0, y: 0, z: 1) | |
) | |
Button { | |
// | |
withAnimation { | |
flipAngle = (flipAngle == .zero) ? 360 : .zero | |
} | |
} label: { | |
Text("Flip") | |
} | |
.buttonStyle(.borderedProminent) | |
} | |
} | |
} | |
#Preview { | |
DefaultAnimationWithAnimation() | |
.preferredColorScheme(.dark) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment