-
Here's what we have done now with the struct PlaybackDurationDemo: View {
let animation: LottieAnimation? = LottieAnimation.named("check")
var body: some View {
LottieView {
animation
}
.animationSpeed(animation!.speedToPlay(forDuration: 10))
.playing()
}
}
extension LottieAnimation {
var timeInterval: TimeInterval {
(endFrame - startFrame) / framerate
}
func speedToPlay(forDuration duration: TimeInterval) -> Double {
timeInterval / duration
}
} Would love to know if this approach is correct or if there is an easier way. |
Beta Was this translation helpful? Give feedback.
Answered by
calda
Jan 27, 2024
Replies: 1 comment 3 replies
-
Your approach makes sense to me. Alternatively you could create a view modifier in an extension like |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another option is to use a
.configure { ... }
with something like this:This could be wrapped up in a custom view modifier like
.duration(10)
and seems appealing since then you don't have to pass the animation into the view modifier.