无论我正在创建的 View 是 LOTAnimatedSwitch 还是 View,动画的图像总是显得非常小。 lottie 动画不会占用我创建的 View 的大小。这是从 LottieFiles 下载动画的问题吗?文件的尺寸为 600x600 像素。我正在使用 Lottie 2.5.0 版和 Swift 4。例如:
let animatedSwitch = LOTAnimatedSwitch(named: "toggle_switch")
animatedSwitch.frame.origin = CGPoint(x: 8, y: separatorLineView.frame.height + separatorLineView.frame.origin.y + 8)
animatedSwitch.frame.size = CGSize(width: dialogViewWidth - 16, height: 40)
animatedSwitch.setProgressRangeForOnState(fromProgress: 0.5, toProgress: 1)
animatedSwitch.setProgressRangeForOffState(fromProgress: 0, toProgress: 0.5)
animatedSwitch.contentMode = .scaleAspectFill
animatedSwitch.clipsToBounds = true
animatedSwitch.backgroundColor = .purple
最佳答案
问题出在我从 LottieFiles 下载的文件上。为了避免动画/图标变小,我在 adobe after effects 中缩放了构图大小以适合预览帧。我使用 bodymovin 插件将 .aeb 文件导出为 .json。
Hardik 的回答也很有帮助。问题很简单,我下载的文件在实际图标周围有很多空白区域,直到我按比例放大图片。
关于swift - LottieAnimationView 大小不会改变/太小(iOS/Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51177088/