<!--
{
  "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(_:trigger:content:animation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13PhaseAnimatorV_7trigger7content9animationACyxq_Gqd___qd_0_q_xcAA9AnimationVSgxctc7ElementQyd__RszSTRd__SQRd_0_r0_lufc"
  },
  "title" : "init(_:trigger:content:animation:)"
}
-->

# init(_:trigger:content:animation:)

Cycles through a sequence of phases in response to changes in a
specified value, animating updates to a view on each phase change.

```
nonisolated init(_ phases: some Sequence<Phase>, trigger: some Equatable, @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.

`trigger`

A value whose changes cause the animator to use the
next phase.

`content`

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

`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.
When the value of the `trigger` input changes, the animator
reevaluates the `content` closure using the value from the second phase
and animates the change. This procedure repeats with each
successive phase until reaching the last phase, at which point
the animator loops back to the first phase.

---

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)