<!--
{
  "availability" : [
    "iOS: 2.0.0 - 13.0.0",
    "iPadOS: 2.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "tvOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIView/setAnimationTransition(_:for:cache:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIView(cm)setAnimationTransition:forView:cache:"
  },
  "title" : "setAnimationTransition(_:for:cache:)"
}
-->

# setAnimationTransition(_:for:cache:)

Sets a transition to apply to a view during an animation block.

```
class func setAnimationTransition(_ transition: UIView.AnimationTransition, for view: UIView, cache: Bool)
```

## Parameters

`transition`

A transition to apply to `view`. Possible values are described in [`UIView.AnimationTransition`](/documentation/UIKit/UIView/AnimationTransition).

`view`

The view to apply the transition to.

`cache`

If <doc://com.apple.documentation/documentation/Swift/true>, the before and after images of `view` are rendered once and used to create the frames in the animation. Caching can improve performance but if you set this parameter to <doc://com.apple.documentation/documentation/Swift/true>, you must not update the view or its subviews during the transition. Updating the view and its subviews may interfere with the caching behaviors and cause the view contents to be rendered incorrectly (or in the wrong location) during the animation. You must wait until the transition ends to update the view.

    If     <doc://com.apple.documentation/documentation/Swift/false>    , the view and its contents must be updated for each frame of the transition animation, which may noticeably affect the frame rate.

## Discussion

If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of [`UIView`](/documentation/UIKit/UIView), as follows:

1. Begin an animation block.
2. Set the transition on the container view.
3. Remove the subview from the container view.
4. Add the new subview to the container view.
5. Commit the animation block.

Use of this method is discouraged in iOS 4.0 and later. You should use the [`transition(with:duration:options:animations:completion:)`](/documentation/UIKit/UIView/transition(with:duration:options:animations:completion:)) method to perform transitions instead.

---

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)