CGAnimateImageDataWithBlock(_:_:_:)
Animate the sequence of images using data from a Graphics Interchange Format (GIF) or Animated Portable Network Graphics (APNG) file file.
Declaration
func CGAnimateImageDataWithBlock(_ data: CFData, _ options: CFDictionary?, _ block: @escaping CGImageSourceAnimationBlock) -> OSStatusParameters
- data:
The image data to animate.
- options:
Additional playback options. Include the Kcgimageanimationdelaytime or Kcgimageanimationloopcount keys to override the timing information in the image file. Include the 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
A status code indicating the success or failure of the animation.
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 image’s metadata. To override the default timing information, provide the appropriate keys in the options dictionary.