LottieAnimationView 大小不会改变/太小(iOS/Swift)

Jaz*_*ure 5 swift lottie

无论我创建的视图是 LOTAnimatedSwitch 还是 View,动画的图像总是显得很小。lottie 动画不占用我创建的视图的大小。这是从 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
Run Code Online (Sandbox Code Playgroud)

Jaz*_*ure 4

问题出在我从 LottieFiles 下载的文件上。为了修复动画/图标过小的问题,我在 adobe aftereffects 中缩放了合成尺寸以适合预览帧。我使用 bodymovin 插件将 .aeb 文件导出为 .json。

哈迪克的回答也很有帮助。问题很简单,我下载的文件在实际图标周围有很多空白区域,直到我放大图片为止。