GIFAnimatable
public protocol GIFAnimatable: class
The protocol that view classes need to conform to to enable animated GIF support.
-
Responsible for managing the animation frames.
Declaration
Swift
var animator: Animator?
-
Notifies the instance that it needs display.
Declaration
Swift
var layer: CALayer
-
View frame used for resizing the frames.
Declaration
Swift
var frame: CGRect
-
Content mode used for resizing the frames.
Declaration
Swift
var contentMode: UIViewContentMode
-
intrinsicContentSize
Extension methodReturns the intrinsic content size based on the size of the image.
Declaration
Swift
public var intrinsicContentSize: CGSize
-
gifLoopDuration
Extension methodTotal duration of one animation loop
Declaration
Swift
public var gifLoopDuration: TimeInterval
-
activeFrame
Extension methodReturns the active frame if available.
Declaration
Swift
public var activeFrame: UIImage?
-
frameCount
Extension methodTotal frame count of the GIF.
Declaration
Swift
public var frameCount: Int
-
isAnimatingGIF
Extension methodIntrospect whether the instance is animating.
Declaration
Swift
public var isAnimatingGIF: Bool
-
animate(withGIFNamed:loopCount:)
Extension methodPrepare 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 methodPrepare 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.
-
prepareForAnimation(withGIFNamed:loopCount:completionHandler:)
Extension methodPrepares the animator instance for animation.
Declaration
Swift
public func prepareForAnimation(withGIFNamed imageName: String, loopCount: Int = 0, completionHandler: ((Void) -> Void)? = .none)
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 methodPrepare for animation and start animating immediately.
Declaration
Swift
public func prepareForAnimation(withGIFData imageData: Data, loopCount: Int = 0, completionHandler: ((Void) -> Void)? = .none)
Parameters
imageData
GIF image data.
loopCount
Desired number of loops, <= 0 for infinite loop.
-
prepareForReuse()
Extension methodStop animating and free up GIF data from memory.
Declaration
Swift
public func prepareForReuse()
-
startAnimatingGIF()
Extension methodStart animating GIF.
Declaration
Swift
public func startAnimatingGIF()
-
stopAnimatingGIF()
Extension methodStop animating GIF.
Declaration
Swift
public func stopAnimatingGIF()
-
setShouldResizeFrames(_:)
Extension methodWhether 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 methodSets 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 methodUpdates the image with a new frame if necessary.
Declaration
Swift
public func updateImageIfNeeded()