---
title: "CGAnimateImageAtURLWithBlock(_:_:_:)"
framework: imageio
role: symbol
role_heading: Function
path: "imageio/cganimateimageaturlwithblock(_:_:_:)"
---

# CGAnimateImageAtURLWithBlock(_:_:_:)

Animate the sequence of images in the Graphics Interchange Format (GIF) or Animated Portable Network Graphics (APNG) file at the specified URL.

## Declaration

```swift
func CGAnimateImageAtURLWithBlock(_ url: CFURL, _ options: CFDictionary?, _ block: @escaping CGImageSourceAnimationBlock) -> OSStatus
```

## Parameters

- `url`: The URL of the image file.
- `options`: Additional playback options. Include the doc://com.apple.imageio/documentation/ImageIO/kCGImageAnimationDelayTime or doc://com.apple.imageio/documentation/ImageIO/kCGImageAnimationLoopCount keys to override the timing information in the image file. Include the doc://com.apple.imageio/documentation/ImageIO/kCGImageAnimationStartIndex key to specify the index of the first image in the animation.
- `block`: The animation block to execute for each image frame. The system executes this block on the main queue, and at the intervals indicated by the image’s delay time metadata. Use this block to display the provided image in your interface.

## Return Value

Return Value A status code indicating the success or failure of the animation.

## Discussion

Discussion The function executes the provided block for each frame of the animation. By default, the function uses the timing information contained in the image’s metadata. This information includes the number of seconds between individual frames, and the number of times to loop the animation. For example, the function uses the kCGImagePropertyGIFDelayTime and kCGImagePropertyGIFLoopCount tags from a GIF file’s metadata. To override the default timing information, provide the appropriate keys in the options dictionary.

## See Also

### Animations

- [CGAnimateImageDataWithBlock(_:_:_:)](imageio/cganimateimagedatawithblock(_:_:_:).md)
- [CGImageSourceAnimationBlock](imageio/cgimagesourceanimationblock.md)
- [kCGImageAnimationStartIndex](imageio/kcgimageanimationstartindex.md)
- [kCGImageAnimationDelayTime](imageio/kcgimageanimationdelaytime.md)
- [kCGImageAnimationLoopCount](imageio/kcgimageanimationloopcount.md)
- [CGImageAnimationStatus](imageio/cgimageanimationstatus.md)
