Created
April 12, 2022 23:09
-
-
Save smrfeld/c93c66a7210dede1f2ca92afb4d6297c to your computer and use it in GitHub Desktop.
CircleAnimation modifier
This file contains hidden or 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
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