Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created March 17, 2024 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/8e501a906c33b413eec81365fe6204fc to your computer and use it in GitHub Desktop.
Save amosgyamfi/8e501a906c33b413eec81365fe6204fc to your computer and use it in GitHub Desktop.
//
// 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