<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/PhaseAnimator/init(_:content:animation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13PhaseAnimatorV_7content9animationACyxq_Gqd___q_xcAA9AnimationVSgxctc7ElementQyd__RszSTRd__lufc"
  },
  "title" : "init(_:content:animation:)"
}
-->

# init(_:content:animation:)

Cycles through a sequence of phases continuously, animating updates to
a view on each phase change.

```
nonisolated init(_ phases: some Sequence<Phase>, @ContentBuilder content: @escaping (Phase) -> Content, animation: @escaping (Phase) -> Animation? = { _ in .default })
```

## Parameters

`phases`

The sequence of phases to cycle through. Ensure that the
sequence isn’t empty. If it is, SwiftUI logs a runtime warning and
also returns a visual warning as the output view.

`content`

A content builder closure that takes the current phase as an
input. Return a view that’s based on the current phase.

`animation`

A closure that takes the current phase as input. Return
the animation to use when transitioning to the next phase. If you
return `nil`, the transition doesn’t animate. If you don’t set this
parameter, SwiftUI uses a default animation.

## Discussion

When the phase animator first appears, this initializer renders the
`content` closure using the first phase as input to the closure.
The animator then begins immediately animating to the view produced by
sending the second phase to the `content` closure using
the animation returned from the `animation` closure. This procedure
repeats for successive phases until reaching the last phase, after which
the animator loops back to the first phase again.

---

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)