Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Dynamic Image

PonyCui edited this page Apr 1, 2019 · 2 revisions

You may replace an element in animation file like this sample.

Download Sample File

You can download a sample file from SVGA-Samples to try.

Step

Load animation as usual.

// Setup a SVGAPlayer by yourself.
SVGAParser *parser = [[SVGAParser alloc] init];
[parser parseWithURL:[NSURL URLWithString:@"https://github.com/yyued/SVGA-Samples/blob/master/kingset.svga?raw=true"] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
    
} failureBlock:nil];

Setup replacing UIImage.

[...aPlayer setImage:iconImage forKey:@"99"];
// or
[...aPlayer setImageWithURL:[NSURL URLWithString: @"https://github.com/PonyCui/resources/blob/master/svga_replace_avatar.png?raw=true"] forKey:@"99"];

ImageKey

The imageKey is the name of png file, ask your designer tell you the file name.

For example, the layer png image file name is xxx.png, imageKey is xxx. File name should always use English name, do not use Chinese or Japanese etc.

Clone this wiki locally