Created
November 27, 2024 01:42
-
-
Save amosgyamfi/faf16bd689d4ecda8544d3069e799266 to your computer and use it in GitHub Desktop.
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
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