Kingfisher Documentation

Class Animated​Image​View

open class AnimatedImageView: UIImageView  

Represents a subclass of UIImageView for displaying animated image. Different from showing animated image in a normal UIImageView (which load all frames at one time), AnimatedImageView only tries to load several frames (defined by framePreloadCount) to reduce memory usage. It provides a tradeoff between memory usage and CPU time. If you have a memory issue when using a normal image view to load GIF data, you could give this class a try.

Kingfisher supports setting GIF animated data to either UIImageView and AnimatedImageView out of box. So it would be fairly easy to switch between them.

%177 AnimatedImageView AnimatedImageView AnimatorDelegate AnimatorDelegate AnimatedImageView->AnimatorDelegate UIImageView UIImageView AnimatedImageView->UIImageView

Nested Types

AnimatedImageView.RepeatCount

Enumeration that specifies repeat count of GIF

AnimatedImageView.Animator

An animator which used to drive the data behind AnimatedImageView.

Conforms To

UIImageView

Properties

auto​Play​Animated​Image

public var autoPlayAnimatedImage = true

Whether automatically play the animation when the view become visible. Default is true.

frame​Preload​Count

public var framePreloadCount = 10

The count of the frames should be preloaded before shown.

needs​Prescaling

public var needsPrescaling = true

Specifies whether the GIF frames should be pre-scaled to the image view's size or not. If the downloaded image is larger than the image view's size, it will help to reduce some memory use. Default is true.

background​Decode

public var backgroundDecode = true

Decode the GIF frames in background thread before using. It will decode frames data and do a off-screen rendering to extract pixel information in background. This can reduce the main thread CPU usage.

run​Loop​Mode

public var runLoopMode = KFRunLoopModeCommon  

The animation timer's run loop mode. Default is RunLoop.Mode.common. Set this property to RunLoop.Mode.default will make the animation pause during UIScrollView scrolling.

repeat​Count

public var repeatCount = RepeatCount.infinite  

The repeat count. The animated image will keep animate until it the loop count reaches this value. Setting this value to another one will reset current animation.

Default is .infinite, which means the animation will last forever.

delegate

public weak var delegate: AnimatedImageViewDelegate? 

Delegate of this AnimatedImageView object. See AnimatedImageViewDelegate protocol for more.

animator

public private(set) var animator: Animator? 

The Animator instance that holds the frames of a specific image in memory.

image

override open var image: KFCrossPlatformImage?  

is​Highlighted

open override var isHighlighted: Bool  

is​Animating

override open var isAnimating: Bool  

Methods

start​Animating()

override open func startAnimating()  

Starts the animation.

stop​Animating()

override open func stopAnimating()  

Stops the animation.

display(_:​)

override open func display(_ layer: CALayer)  

did​Move​ToWindow()

override open func didMoveToWindow()  

did​Move​ToSuperview()

override open func didMoveToSuperview()