ios - 调用时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()
解决方案
推荐阅读
- javascript - 如何使用 Firebase SDK 跟踪连接或在线状态?
- image - 运行我的 codeigniter 应用程序的 docker 映像时出现问题
- flutter - Firestore如何将数据保存在子集合中
- c++ - 素数的布尔函数总是返回真
- linux - 如何将文件夹的全部内容移动到其子文件夹
- python-3.x - cv2.error : OpenCV(4.5.3) 错误:错误参数和重载解析在 cv.line 中失败
- python - 为什么我的 Python 数据类没有正确初始化布尔值?
- oracle - Oracle 内存列存储没有改进 SELECT 查询?
- c# - 如何在模态中触发模型验证?.NET 5
- javascript - 我可以延迟加载 html 卡吗?/我想在滚动时渲染它