Skip to content
Elegant SVG animation kit for swift
Branch: master
Clone or download
kzumu Merge pull request #2 from InnaLMC/feature/init_from_file
support SVGView and css file init from local file, made init methods more safety
Latest commit df84cb0 Jun 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Elephant.xcodeproj Update deployment target May 23, 2019
Example-iOS support SVGView and css file init from local file, not only bundle, m… Jun 7, 2019
Sources moved html building from Style to separated struct Jun 13, 2019
Tests Fixed paths May 22, 2019
.gitignore Project init May 20, 2019
Elephant.podspec Fixed podspec May 24, 2019
LICENSE Add License, Readme, podspec May 23, 2019
README.md

README.md

Elephant

This is SVG animation presentation kit for iOS.

Swift5 Release CocoaPods Carthage
Platform Lincense

Example

You can run example app. Please open Example-iOS/Elephant-iOS.xcworkspace!

Usage

You can display the svg image with animation.

We are supportted two animation formats😎

The format is below.

  • Animation in SVG
  • Animation in CSS

Usage is difference by the format.

SVGView initialization

This is initialization SVGView for format 1 (Animation in SVG) usage.

SVGView(named: "svg-filename", animationOwner: .svg)

This is initialization SVGView for format 2 (Animation in CSS) usage.

SVGView(named: "svg-filename", animationOwner: .css, style: .cssFile(name: "css-filename"))

Show in your ViewController

And, you initialized view, you have to do is only add view to parent view, and start animation like below.

class ViewController: UIViewController {
    let svgView = SVGView(named: "image", animationOwner: .svg)

    override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(svgView)
        svgView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            svgView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            svgView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            svgView.widthAnchor.constraint(equalToConstant: 400),
            svgView.heightAnchor.constraint(equalToConstant: 400),
        ])

        svgView.startAnimation() 

        // svgView.stopAnimation()    // Stop animation.

        // svgView.isAnimate { [weak self] (value, error) in
        //     if let error = error {
        //         print(error)
        //     } 
        //     guard let value = value else { return } // value means whether animation is moving.
        // }
    }
}
  

Requirements

  • Xcode 10.2
  • Swift 5.0

Installation

CocoaPods

Add this to Podfile

pod 'Elephant'
$ pod install

Carthage

Carthage

Add this to Cartfile

github "kzumu/Elephant"
$ carthage update --platform ios

Author

Kazumasa Shimomura

License

Elephant is available under the Apache v2. See the LICENSE file for more info.

FOSSA Status

You can’t perform that action at this time.