【问题标题】:Lottie iOS animation is not working in mobileLottie iOS 动画在移动设备上不起作用
【发布时间】:2022-01-28 15:02:27
【问题描述】:

我们尝试在 iOS 应用中实现 Lottie 动画。我们添加了一个 json 文件,该文件在 android 和 web 中运行良好,但在 iOS 中不可用,即标题是不可见的,并且背景上出现了额外的行。这是sn-p用来播放Lottie动画的代码:

animationView = .init(name: "experts") // json file name
animationView?.frame = view.bounds
animationView?.contentMode = .scaleAspectFill
animationView?.loopMode = .playOnce
animationView?.animationSpeed = 0.5
view.addSubview(animationView!)
animationView?.play { (finished) in
    // animation is finished
}

Lottie iOS 版本 - 3.3.0 Xcode 版本 - 12.4 iOS 版本 - 12.5/15.3

【问题讨论】:

  • 可以分享一下目前的动画和期待吗?

标签: ios swift


【解决方案1】:

试试下面的代码,它工作正常:-

animationView.animation = Animation.named("74683-delivery") //JSON file name
animationView.center = view.center
animationView.frame = view.bounds
animationView.backgroundColor = .white
animationView.contentMode = .scaleAspectFit
animationView.loopMode = .playOnce
animationView.play()
view.addSubview(animationView)

【讨论】:

  • 感谢代码!我尝试了您的解决方案,但它没有按预期工作。
  • 能否提供您的 JSON 文件和问题的屏幕截图?
  • 标题在应用程序中不可见。当这个 json 文件被加载时。
猜你喜欢
  • 2015-04-28
  • 1970-01-01
  • 2017-07-12
  • 1970-01-01
  • 2022-07-21
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
  • 1970-01-01
相关资源
最近更新 更多