<!--
{
  "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/View/phaseAnimator(_:trigger:content:animation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE13phaseAnimator_7trigger7content9animationQrqd_0__qd_1_qd_2_AA018PlaceholderContentC0VyxG_qd__tcAA9AnimationVSgqd__ctSQRd__7ElementQyd_0_Rsd__STRd_0_SQRd_1_AaBRd_2_r2_lF"
  },
  "title" : "phaseAnimator(_:trigger:content:animation:)"
}
-->

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

Animates effects that you apply to a view over a sequence of phases
that change based on a trigger.

```
nonisolated func phaseAnimator<Phase>(_ phases: some Sequence, trigger: some Equatable, @ContentBuilder content: @escaping (PlaceholderContentView<Self>, Phase) -> some View, animation: @escaping (Phase) -> Animation? = { _ in .default }) -> some View where Phase : Equatable
```

## 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 two parameters: a proxy
value representing the modified view and the current phase.
You can apply effects to the proxy 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 modified view first appears, this modifier renders its
`content` closure using the first phase as input to the closure,
along with a proxy for the modified view. Apply effects to the
proxy — and thus to the modified view — in a way that’s appropriate
for the first phase value.

Later, when the value of the `trigger` input changes, the modifier
provides its `content` closure with the value of the second phase.
Update the effects that you apply to the proxy view accordingly,
and the modifier animates the change for you. The next time the
`trigger` input changes, this procedure repeats using successive phases
until reaching the last phase, at which point the modifier 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)