Elephant 0.1.0

Elephant 0.1.0

Kazumasa Shimomura维护。



Elephant 0.1.0

Elephant

这是iOS的SVG动画演示套件。

Swift5 Release CocoaPods Carthage
Platform Lincense

示例

您可以运行示例应用。请打开Example-iOS/Elephant-iOS.xcworkspace

使用

您可以使用动画显示SVG图像。

我们支持两种动画格式😎

格式如下。

  • SVG中的动画
  • CSS中的动画

根据格式使用方式不同。

SVGView初始化

这是初始化格式1(SVG中的动画)的SVGView。

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

这是初始化格式2(CSS中的动画)的SVGView。

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

在您的ViewController中显示

并且,你已经初始化了视图,你只需将视图添加到父视图并启动以下动画即可。

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.
        // }
    }
}
  

需求

  • Xcode 10.2
  • Swift 5.0

安装

CocoaPods

将以下内容添加到 Podfile

pod 'Elephant'
$ pod install

Carthage

Carthage

将以下内容添加到 Cartfile

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

作者

Kazumasa Shimomura

许可协议

Elephant 与 Apache v2 许可协议一致。更多信息请查看 LICENSE 文件。