Skip to content

Instantly share code, notes, and snippets.

@smrfeld
Created April 12, 2022 23:09
Show Gist options
  • Save smrfeld/c93c66a7210dede1f2ca92afb4d6297c to your computer and use it in GitHub Desktop.
Save smrfeld/c93c66a7210dede1f2ca92afb4d6297c to your computer and use it in GitHub Desktop.
CircleAnimation modifier
struct CircleAnimation: AnimatableModifier {
var angle: Float
var radius: Float
var animatableData: Float {
get { angle }
set { angle = newValue }
}
func body(content: Content) -> some View {
let x = CGFloat(400 + radius * cos(angle))
let y = CGFloat(400 - radius * sin(angle))
content.position(x: x, y: y)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment