Lottie导入和使用

Lottie 是一个可应用于Andriod和iOS的动画库,可以使用AE导出的json高效创建动画。

一.通过cocoapods集成

1.在你的podfile中添加:

pod 'lottie-ios'

2.运行

pod install

然后导入import   Lottie运行,很可能会编译报错,据文档介绍,可能和之前集成过的一些第三方有关,比如Masonry等。那就按文档来进行第二步。

二.安装Carthage

1.安装homebrew:

第一步:在命令行粘贴:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

第二步:输入命令 brew update

2.安装Carthage:

brew install carthage

可用carthage version查看Carthage版本号

3.使用Carthage安装依赖:

第一步:cd ~/路径/项目文件夹

第二步:创建一个空的 Carthage 文件 Cartfile

touch Cartfile

第三步:使用 Xcode 打开 Cartfile 文件

open-a Xcode Cartfile

第四步:在cartfile里面加一行代码

github "airbnb/lottie-ios" "master"

第五步:终端执行更新命令

carthage update --platform iOS

现在可以重新编译,可能还会报找不到Lottie头文件的问题,不必担心,可耐心多次重启Xcode,反复clean和build即可。

三.使用Lottie播放动画:

实例代码:


Lottie导入和使用_第1张图片


Lottie导入和使用_第2张图片

你可能感兴趣的:(Lottie导入和使用)