SwiftUI: Repeat animation forever with delay at the end, without autoreverse
Asked Answered
W

0

7

I want to repeat an animation forever, without it to autoreverse, and with a delay/pause between the repetitions after the animation played.

I know there is a .delay() modifier, but it delays the beginning of the animation:

let ani = Animation.easeInOut.delay(1.0).repeatForever(autoreverses: false)

In addition with the .repeatForever modifier, after the animation played it immediately jumps back to its beginning. But I want the last keyframe to remain visible on the screen for a short amount of time.

I’ve also tried it the other way around, adding a .delay() after the .repeatForever modifier, but without success (delay has no effect).

let ani = Animation.easeInOut.repeatForever(autoreverses: false).delay(1.0)

How can I add a delay after the animation played?

Whistle answered 19/3, 2022 at 11:6 Comment(2)
You can try using GeometryEffect for a key frame based animation swiftui-lab.com/swiftui-animations-part2 Swiftui Animation by itself is not easy to synchronize.Tooling
Timing curve might do it too objc.io/blog/2019/09/26/swiftui-animation-timing-curvesTooling

© 2022 - 2025 — McMap. All rights reserved.