36.3 Repeating an Animation
By default, an animation will be performed once each time it is initiated. An animation may, however, be configured to repeat one or more times. In the following example, the animation is configured to repeat a specific number of times:
.animation(Animation.linear(duration: 1).repeatCount(10))
Each time an animation repeats, it will perform the animation in reverse as the view returns to its original state. If the view is required to instantly revert to its original appearance before repeating the animation, the autoreverses parameter must be set to false:
.animation(Animation.linear(duration: 1).repeatCount(10,
autoreverses: false))
An animation may also be configured to repeat indefinitely using the repeatForever() modifier as follows:
.repeatForever(autoreverses: true))