Giter Site home page Giter Site logo

hhy5277 / svgaplayer-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svga/svgaplayer-ios

0.0 1.0 0.0 1.89 MB

Similar to Lottie. Render After Effects / Animate CC (Flash) animations natively on Android and iOS, Web. 使用 SVGAPlayer 在 Android、iOS、Web中播放 After Effects / Animate CC (Flash) 动画。

Home Page: http://svga.io

License: Apache License 2.0

Ruby 1.88% Objective-C 98.12%

svgaplayer-ios's Introduction

SVGAPlayer

简体中文

Supporting SVGA Library

SVGA is an Apache-licensed open source project. And now SVGA library with its ongoing development made possible entirely by the support of PonyCui and errnull. To support SVGA library development, please consider:

Introduce

SVGAPlayer is a light-weight animation renderer. You use tools to export svga file from Adobe Animate CC or Adobe After Effects, and then use SVGAPlayer to render animation on mobile application.

SVGAPlayer-iOS render animation natively via iOS CoreAnimation Framework, brings you a high-performance, low-cost animation experience.

If wonder more information, go to this website.

Usage

Here introduce SVGAPlayer-iOS usage. Wonder exporting usage? Click here.

Install Via CocoaPods

You want to add pod 'SVGAPlayer', '~> 2.3' similar to the following to your Podfile:

target 'MyApp' do pod 'SVGAPlayer', '~> 2.3' end

Then run a pod install inside your terminal, or from CocoaPods.app.

Locate files

SVGAPlayer could load svga file from application bundle or remote server.

Using code

Create a SVGAPlayer instance.

SVGAPlayer *player = [[SVGAPlayer alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[self.view addSubview:player]; // Add subview by yourself.

Create a SVGAParser instance, parse from bundle like this.

SVGAParser *parser = [[SVGAParser alloc] init];
[parser parseWithNamed:@"posche" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
    
} failureBlock:nil];

Create a SVGAParser instance, parse from remote server like this.

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

Set videoItem to SVGAPlayer, play it as you want.

[parser parseWithURL:[NSURL URLWithString:@"https://github.com/yyued/SVGA-Samples/blob/master/posche.svga?raw=true"] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
    if (videoItem != nil) {
        player.videoItem = videoItem;
        [player startAnimation];
    }
} failureBlock:nil];

Cache

SVGAParser use NSURLSession request remote data via network. You may use following ways to control cache.

Response Header

Server response SVGA files in Body, and response header either. response header has cache-control / etag / expired keys, all these keys telling NSURLSession how to handle cache.

Request NSData By Yourself

If you couldn't fix Server Response Header, You should build NSURLRequest with CachePolicy by yourself, and fetch NSData.

Deliver NSData to SVGAParser, as usual.

Features

Here are many feature samples.

APIs

Head on over to https://github.com/yyued/SVGAPlayer-iOS/wiki/APIs

svgaplayer-ios's People

Contributors

ponycui avatar smallblackcat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.