Created
March 17, 2024 09:18
-
-
Save amosgyamfi/8e501a906c33b413eec81365fe6204fc 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: 1, y: 0, z: 0)) | |
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