Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created November 27, 2024 01:42
Show Gist options
  • Save amosgyamfi/faf16bd689d4ecda8544d3069e799266 to your computer and use it in GitHub Desktop.
Save amosgyamfi/faf16bd689d4ecda8544d3069e799266 to your computer and use it in GitHub Desktop.
import SwiftUI
struct MoveFromAToB: View {
// Define the two points for horizontal animation
let pointA = CGPoint(x: 60, y: 330) // Changed x to 50
let pointB = CGPoint(x: 700, y: 330) // Changed x to 350
var body: some View {
PhaseAnimator([pointA, pointB]) { point in
Circle()
.fill(Color.blue)
.frame(width: 80, height: 80)
.position(point)
} animation: { _ in
.spring(duration: 1, bounce: 0.3)
}
}
}
#Preview {
MoveFromAToB()
}
// End of file. No additional code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment