<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Animation/repeatForever(autoreverses:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI9AnimationV13repeatForever12autoreversesACSb_tF"
  },
  "title" : "repeatForever(autoreverses:)"
}
-->

# repeatForever(autoreverses:)

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

```
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

An animation that continuously repeats.

## 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
                }
            }
    }
}
```

![A video that shows a gear that continuously rotates clockwise.](videos/com.apple.SwiftUI/animation-17-repeat-forever.mp4)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)