首页 > 解决方案 > 调用时AnimationView不出现

问题描述

我正在使用 Lottie API 在我的一个静态表格视图单元格中使用以下代码创建自定义动画视图。但是,视图没有出现。

我已经测试了其他 Lottie 文件,因此它不是该文件。而且我还通过更改它的backgroundColor工作来测试单元格,所以我打电话给正确的单元格。

let index = IndexPath(row: 9, section: 0)

let cellWidth = self.tableView.cellForRow(at: index)?.frame.size.width
let cellHeight = self.tableView.cellForRow(at: index)?.frame.size.height

let animationView = LOTAnimationView(name: "loader1")
self.animationView.frame = CGRect(x: 0, y: 0, width: cellWidth! / 2, height: 50)
self.animationView.center = (self.tableView.cellForRow(at: index)?.center)!
self.animationView.contentMode = .scaleAspectFill
self.animationView.loopAnimation = true

self.tableView.cellForRow(at: index)?.addSubview(self.animationView)

self.animationView.play()

标签: iosswiftlottie

解决方案


推荐阅读