<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIImage/animatedImage(with:duration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIImage(cm)animatedImageWithImages:duration:"
  },
  "title" : "animatedImage(with:duration:)"
}
-->

# animatedImage(with:duration:)

Creates and returns an animated image from an existing set of images.

```
class func animatedImage(with images: [UIImage], duration: TimeInterval) -> UIImage?
```

## Parameters

`images`

An array of [`UIImage`](/documentation/UIKit/UIImage) objects.

`duration`

The duration of the animation.

## Return Value

A new image object.

## Discussion

All images included in the animated image should share the same size and scale.

---

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)