APIs
SVGAPlayer
The SVGAPlayer used to render animation, extends UIView
videoItem: SVGAVideoEntity
The current playing video item.
loops: int
Defaults to 0.
How many times should animation loops. 0 means Infinity Loop.
clearsAfterStop: BOOL
Defaults to true.
Clears canvas after animation stop.
fillMode: NSString
Defaults to Forward. Could be Forward, Backward.
Forward means animation will pause on last frame after finished.
Backward means animation will pause on first frame after finished.
delegate: id<SVGAPlayerDelegate>
SVGAPlayer send events to delegate object.
- (void)startAnimation;
Play animation from zero frame.
- (void)startAnimationWithRange:(NSRange)range reverse:(BOOL)reverse;
Play animation in specific range. If reverse sets to true, animation will play from end to start reversely.
- (void)pauseAnimation;
Pause animation and stop on current frame.
- (void)stopAnimation;
Stop animation, and clear canvas if clearsAfterStop sets to true.
- (void)stepToFrame:(NSInteger)frame andPlay:(BOOL)andPlay;
Render specific frame, play from this frame if andPlay sets to true.
- (void)stepToPercentage:(CGFloat)percentage andPlay:(BOOL)andPlay;
Render specific percentage frame, the percentage value should from 0.0 to 1.0, play from this frame if andPlay sets to true.
- (void)setHidden:(BOOL)hidden forKey:(NSString *)aKey;
Dynamic hidden an element.
- (void)setImage:(UIImage *)image forKey:(NSString *)aKey;
Dynamic replace an element with a Bitmap.
- (void)setImageWithURL:(NSURL *)URL forKey:(NSString *)aKey;
Dynamic replace an element with a network Bitmap.
- (void)setAttributedText:(NSAttributedString *)attributedText forKey:(NSString *)aKey;
Add text above an element.
- (void)setDrawingBlock:(SVGAPlayerDynamicDrawingBlock)drawingBlock forKey:(NSString *)aKey;
Draw on element.
- (void)clearDynamicObjects;
Reset all dynamic object.
SVGAParser
parseWithNamed:(nonnull NSString *)named ...
Parse a svga file from bundle directory.
parseWithURL:(nonnull NSURL *)URL ...
Parse a remote file from network.
parseWithURLRequest:(nonnull NSURLRequest *)URLRequest ...
Parse a remote file from network.
parseWithData:(nonnull NSData *)data cacheKey:(nonnull NSString *)cacheKey ...
Parse a svga file from stream, the cacheKey should be unique betweens files. If closeInputStream sets to true, stream will close after parse.
SVGAPlayerDelegate
- (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player;
Trigger after animation finished.
Notice: delegate could never trigger when loops = 0.
- (void)svgaPlayerDidAnimatedToFrame:(NSInteger)frame;
Trigger after animation play to specific frame.
- (void)svgaPlayerDidAnimatedToPercentage:(CGFloat)percentage;
Trigger after animation play to specific percentage (from 0.0 to 1.0).