无论我创建的视图是 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)