Skip to content

使用 XAnimation, 你可以快速将设计师设计的lottie动效,应用到你的 App 中现有的任何视图(或图层)上

License

Notifications You must be signed in to change notification settings

jd-opensource/XAnimation

Repository files navigation

XAnimation

CI Status Version License Platform

Introduce 简介 😊

使用 XAnimation, 你可以快速将设计师设计的动画效果,应用到你的 App 中现有的任何视图(或图层)上,由于 XAnimation 基于 Lottie 进行二次开源,因此它同样具备以下特征:

  • 高还原度 🎆
  • 少代码 ♻️
  • 高稳定性 💪

Example 效果预览

你可以在 Example 工程中体验它。

Requirements

iOS 9.0+

Installation 安装

XAnimation 可以通过 CocoaPods 来安装 (https://cocoapods.org) 只需要将下面代码加入到 Podfile 中。

pod install 'XAnimation'

API 使用

以下调示例为 UIView 绑定动画, CALayer 可以直接去源码看相关接口定义.

  1. 依赖头文件.
#import <XAnimation/UIView+XALottie.h>
#import <XAnimation/XABindLottieController.h>
  1. Lottie 绑定到一个根 UIView(或 CALayer)上.
/**
 * animationName 即为本地Json文件名
 * aView 你的任意一个视图
 */
[aView bindLottieWithAnimationNamed:@"牌子动画(旋转+位移+缩放)"];
  1. 你的视图绑定 Lottie json 中某个图层.
[aView bindLottieLayerName:@"牌子"];
  1. 播放动画.
[[aView currentBindController] play];

Future 展望

请试想,动画绑定的能力该如何运用呢?
每个人可能都有不同想法 🤔, 但这里有一个推荐,我现在对上面的流程做一点点改进,将 App 中的视图和 Lottie 中的图层的绑定关系,改为后台配置,这样流程看起来会像下图:

这样做的好处是:

  • 0 代码开发,任意时刻配置,可立即上线
  • 减少测试环节,由平台提供稳定性,提高效能

好了,现在你能想到哪些配置应用场景呢?比如:春节的时候🧨🧨🧨,让你的大 Icon 开心的跳起来?😄

Author 作者

wangxiyuan (wangxiyuan613@163.com)
如果你有更多更好的想法,欢迎发件交流 🤝🤝🤝。

License 版权

XAnimation is available under the Apache License 2.0. See the LICENSE file for more info.

About

使用 XAnimation, 你可以快速将设计师设计的lottie动效,应用到你的 App 中现有的任何视图(或图层)上

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published