iOS开发

ios开发AE动画库 Lottie Swift版介绍及官方文档翻

2019-04-19  本文已影响0人  20b347b28fc9

ios开发AE动画库 Lottie Swift版介绍


1.Lottie-ios 简介

Lottie 是一个可应用于Andriod和iOS的动画库,它通过bodymovin插件来解析Adobe After Effects 动画并导出为json文件,通过手机端原生的方式或者通过React Native的方式渲染出矢量动画。

2.直达

3.Lottie的优势

4.Lottie的劣势

5.版本简介

5.用法代码举例

let animationV = AnimationView(name: "JSON名") // 如"loading",不用"loading.json"
// 等价于下面这两行代码
// let animation = Animation.named("loading")
// let animationV = AnimationView(animation: animation)
animationV.frame = CGRect(x: 40, y: 40, width: 80, height: 80)
view.addSubview(animationV)
animationV.play()
/// Load from the main bundle.
let animation = Animation("StarAnimation")
/// Load from a specific bundle/
let animation = Animation("StarAnimation", bundle: myBundle)
/// Load from a subdirectory in a bundle.
let animation = Animation("StarAnimation", subdirectory: "Animations")
/// Load with an animation cache.
let animation = Animation("StarAnimation", animationCache: LRUAnimationCache.sharedCache)
let animation = Animation(filepathURL.path, animationCache: LRUAnimationCache.sharedCache)
/// 通过progress (0~1)
animationView.play(fromProgress: 0.5, toProgress: 1)
/// 通过帧时间
animationView.play(fromFrame: 24, toFrame: 48)
/// 通过标签
animationView.play(fromMarker: "ftue1_begin", toMarker: "ftue1_end")
animationView.pause()
animationView.stop()
/// 拉伸模式
var AnimationView.contentMode: UIViewContentMode { get set }
/// 进入后台行为
var AnimationView.backgroundBehavior: LottieBackgroundBehavior { get set }
/// 循环播放模式
var AnimationView.loopMode: LottieLoopMode { get set }
/// 动画播放速度
var AnimationView.animationSpeed: CGFloat { get set }
/// 当前进度
var AnimationView.currentProgress: AnimationProgressTime { get set }

6.官方文档翻译

https://www.jianshu.com/p/207355f796c5

上一篇 下一篇

猜你喜欢

热点阅读