Created
August 9, 2025 13:19
-
-
Save jacobsapps/521a1671609cefa7ae60d5a8c441e1e1 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
struct WeightlifterKeyframes { | |
var verticalScale: Double = 1.0 | |
var verticalOffset: Double = 0.0 | |
} | |
private var weightlifterAnimation: some View { | |
Image(systemName: "figure.strengthtraining.traditional") | |
.resizable() | |
.foregroundStyle(.white) | |
.frame(width: 200, height: 200) | |
.keyframeAnimator( | |
initialValue: WeightlifterKeyframes(), | |
repeating: true | |
) { view, keyframes in | |
view | |
.scaleEffect(y: keyframes.verticalScale, anchor: .bottom) | |
.offset(y: keyframes.verticalOffset) | |
} keyframes: { _ in | |
KeyframeTrack(\.verticalScale) { | |
LinearKeyframe(0.5, duration: 0.25) | |
LinearKeyframe(1.0, duration: 0.25) | |
LinearKeyframe(1.3, duration: 0.25) | |
LinearKeyframe(1.0, duration: 0.25) | |
} | |
KeyframeTrack(\.verticalOffset) { | |
LinearKeyframe(20, duration: 0.25) | |
SpringKeyframe(-40, duration: 0.5, spring: .snappy) | |
CubicKeyframe(0, duration: 0.25) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment