SDAnimatedImageProvider

@protocol SDAnimatedImageProvider <NSObject>

This is the animated image protocol to provide the basic function for animated image rendering. It’s adopted by SDAnimatedImage and SDAnimatedImageCoder

  • The original animated image data for current image. If current image is not an animated format, return nil. We may use this method to grab back the original image data if need, such as NSCoding or compare.

    Declaration

    Objective-C

    @required
    @property (readonly, copy, nonatomic, nullable) NSData *animatedImageData;

    Swift

    var animatedImageData: Data? { get }

    Return Value

    The animated image data

  • Total animated frame count. If the frame count is less than 1, then the methods below will be ignored.

    Declaration

    Objective-C

    @required
    @property (readonly, assign, nonatomic) NSUInteger animatedImageFrameCount;

    Swift

    var animatedImageFrameCount: UInt { get }

    Return Value

    Total animated frame count.

  • Animation loop count, 0 means infinite looping.

    Declaration

    Objective-C

    @required
    @property (readonly, assign, nonatomic) NSUInteger animatedImageLoopCount;

    Swift

    var animatedImageLoopCount: UInt { get }

    Return Value

    Animation loop count

  • Returns the frame image from a specified index.

    Note

    The index maybe randomly if one image was set to different imageViews, keep it re-entrant. (It’s not recommend to store the images into array because it’s memory consuming)

    Declaration

    Objective-C

    - (nullable UIImage *)animatedImageFrameAtIndex:(NSUInteger)index;

    Swift

    func animatedImageFrame(at index: UInt) -> UIImage?

    Parameters

    index

    Frame index (zero based).

    Return Value

    Frame’s image

  • Returns the frames’s duration from a specified index.

    Note

    The index maybe randomly if one image was set to different imageViews, keep it re-entrant. (It’s recommend to store the durations into array because it’s not memory-consuming)

    Declaration

    Objective-C

    - (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index;

    Swift

    func animatedImageDuration(at index: UInt) -> TimeInterval

    Parameters

    index

    Frame index (zero based).

    Return Value

    Frame’s duration