# GIFAnimatable Protocol Reference

# GIFAnimatable

    public protocol GIFAnimatable: class

The protocol that view classes need to conform to to enable animated GIF support.

- `animator`

  Responsible for managing the animation frames.

  #### Declaration

  Swift

      var animator: Animator?

- `layer`

  Notifies the instance that it needs display.

  #### Declaration

  Swift

      var layer: CALayer

- `frame`

  View frame used for resizing the frames.

  #### Declaration

  Swift

      var frame: CGRect

- `contentMode`

  Content mode used for resizing the frames.

  #### Declaration

  Swift

      var contentMode: UIViewContentMode

- `intrinsicContentSize` Extension method

  Returns the intrinsic content size based on the size of the image.

  #### Declaration

  Swift

      public var intrinsicContentSize: CGSize

- `gifLoopDuration` Extension method

  Total duration of one animation loop

  #### Declaration

  Swift

      public var gifLoopDuration: TimeInterval

- `activeFrame` Extension method

  Returns the active frame if available.

  #### Declaration

  Swift

      public var activeFrame: UIImage?

- `frameCount` Extension method

  Total frame count of the GIF.

  #### Declaration

  Swift

      public var frameCount: Int

- `isAnimatingGIF` Extension method

  Introspect whether the instance is animating.

  #### Declaration

  Swift

      public var isAnimatingGIF: Bool

- `animate(withGIFNamed:loopCount:)` Extension method

  Prepare for animation and start animating immediately.

  #### Declaration

  Swift

      public func animate(withGIFNamed imageName: String, loopCount: Int = 0)

  #### Parameters

  `imageName` | The file name of the GIF in the main bundle.
  `loopCount` | Desired number of loops, <= 0 for infinite loop.

- `animate(withGIFData:loopCount:)` Extension method

  Prepare for animation and start animating immediately.

  #### Declaration

  Swift

      public func animate(withGIFData imageData: Data, loopCount: Int = 0)

  #### Parameters

  `imageData` | GIF image data.
  `loopCount` | Desired number of loops, <= 0 for infinite loop.

- `animate(withGIFURL:loopCount:)` Extension method

  Prepare for animation and start animating immediately.

  #### Declaration

  Swift

      public func animate(withGIFURL imageURL: URL, loopCount: Int = 0)

  #### Parameters

  `imageURL` | GIF image url.
  `loopCount` | Desired number of loops, <= 0 for infinite loop.

- `prepareForAnimation(withGIFNamed:loopCount:completionHandler:)` Extension method

  Prepares the animator instance for animation.

  #### Declaration

  Swift

      public func prepareForAnimation(withGIFNamed imageName: String,
                                      loopCount: Int = 0,
                                      completionHandler: (() -> Void)? = nil)

  #### Parameters

  `imageName` | The file name of the GIF in the main bundle.
  `loopCount` | Desired number of loops, <= 0 for infinite loop.

- `prepareForAnimation(withGIFData:loopCount:completionHandler:)` Extension method

  Prepare for animation and start animating immediately.

  #### Declaration

  Swift

      public func prepareForAnimation(withGIFData imageData: Data,
                                      loopCount: Int = 0,
                                      completionHandler: (() -> Void)? = nil)

  #### Parameters

  `imageData` | GIF image data.
  `loopCount` | Desired number of loops, <= 0 for infinite loop.

- `prepareForAnimation(withGIFURL:loopCount:completionHandler:)` Extension method

  Prepare for animation and start animating immediately.

  #### Declaration

  Swift

      public func prepareForAnimation(withGIFURL imageURL: URL,
                                      loopCount: Int = 0,
                                      completionHandler: (() -> Void)? = nil)

  #### Parameters

  `imageURL` | GIF image url.
  `loopCount` | Desired number of loops, <= 0 for infinite loop.

- `prepareForReuse()` Extension method

  Stop animating and free up GIF data from memory.

  #### Declaration

  Swift

      public func prepareForReuse()

- `startAnimatingGIF()` Extension method

  Start animating GIF.

  #### Declaration

  Swift

      public func startAnimatingGIF()

- `stopAnimatingGIF()` Extension method

  Stop animating GIF.

  #### Declaration

  Swift

      public func stopAnimatingGIF()

- `setShouldResizeFrames(_:)` Extension method

  Whether the frame images should be resized or not. The default is `false`, which means that the frame images retain their original size.

  #### Declaration

  Swift

      public func setShouldResizeFrames(_ resize: Bool)

  #### Parameters

  `resize` | Boolean value indicating whether individual frames should be resized.

- `setFrameBufferCount(_:)` Extension method

  Sets the number of frames that should be buffered. Default is 50. A high number will result in more memory usage and less CPU load, and vice versa.

  #### Declaration

  Swift

      public func setFrameBufferCount(_ frames: Int)

  #### Parameters

  `frames` | The number of frames to buffer.

- `updateImageIfNeeded()` Extension method

  Updates the image with a new frame if necessary.

  #### Declaration

  Swift

      public func updateImageIfNeeded()

2015 © Reda Lemeden. See LICENSE for more details.

Generated by jazzy ♪♫ v0.9.0, a Realm project.