JFDynamicLottie
JFDynamicLottie 是一个 Lottie 扩展,可以动态替换 Lottie 资源(如图像、文本)并高效运行 Lottie 动画。
用法
首先设置您本地的 mainBundle
//setup your main bundle directory to save lottie file also you can setup it in appdelete did finish
JFLottieAnimationView.setupMainBundleDirectoryPath(path: "Resource/")
然后尝试使用它。
var textReplacement: [String:String] = [:]
textReplacement["我是用户名1"] = "JerryFans"
textReplacement["我是用户名2"] = "我是被替换的"
textReplacement["我是用户名5"] = "替换后的名字"
var imgReplacement: [String:UIImage] = [:]
let imgView = UIImageView(image: UIImage(named: "snap"))
imgView.frame = CGRect(x: 0, y: 0, width: 92, height: 92)
imgView.layer.cornerRadius = 46
imgView.layer.masksToBounds = true
if let img = imgView.jf.syncSnapshotImage() {
imgReplacement["head_0"] = img
}
self.lottieView?.imageReplacement = imgReplacement
self.lottieView?.textReplacement = textReplacement
更多用法请查看示例代码。
示例
要运行示例项目,请克隆仓库,然后从 Example 目录运行 pod install
安装
JFDynamicLottie 通过 CocoaPods 提供。要安装它,请简单地将以下行添加到 Podfile 中
pod 'JFDynamicLottie'
作者
JerryFans, [email protected]
许可
JFDynamicLottie 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。