---
title: "repeatForever(autoreverses:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/animation/repeatforever(autoreverses:)"
---

# repeatForever(autoreverses:)

Repeats the animation for the lifespan of the view containing the animation.

## Declaration

```swift
func repeatForever(autoreverses: Bool = true) -> Animation
```

## Parameters

- `autoreverses`: A Boolean value that indicates whether the animation sequence plays in reverse after playing forward.

## Return Value

Return Value An animation that continuously repeats.

## Discussion

Discussion Use this method to repeat the animation until the instance of the view no longer exists, or the view’s explicit or structural identity changes. For example, the following code continuously rotates a gear symbol for the lifespan of the view. struct ContentView: View {     @State private var rotationDegrees = 0.0

private var animation: Animation {         .linear         .speed(0.1)         .repeatForever(autoreverses: false)     }

var body: some View {         Image(systemName: "gear")             .font(.system(size: 86))             .rotationEffect(.degrees(rotationDegrees))             .onAppear {                 withAnimation(animation) {                     rotationDegrees = 360.0                 }             }     } }

## See Also

### Configuring an animation

- [delay(_:)](swiftui/animation/delay(_:).md)
- [repeatCount(_:autoreverses:)](swiftui/animation/repeatcount(_:autoreverses:).md)
- [speed(_:)](swiftui/animation/speed(_:).md)
