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

标签 swift lottie

无论我正在创建的 View 是 LOTAnimatedSwitch 还是 View,动画的图像总是显得非常小。 lottie 动画不会占用我创建的 View 的大小。这是从 LottieFiles 下载动画的问题吗?文件的尺寸为 600x600 像素。我正在使用 Lottie 2.5.0 版和 Swift 4。例如:

enter image description here

    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/

相关文章:

ios - 如何创建单列的 Collection View ?

ios - lottie 动画在 ios 中为 nil

swift - 如何从 Firebase 中检索手动输入的数据?

ios - 如何判断购买了哪个IAP?

android - 在运行时动态替换 Lottie 动画中的 Image

json - 使用 lottie-react-web,我收到以下控制台错误 : <svg> attribute viewBox: Expected number,“0 0 undefined undefined

c# - Lottie.Forms - 从 EmbeddedResources 加载

react-native - 更改洛蒂填充颜色 react native

swift - 如何解决此弃用问题 "abs is deprecated: Please use the ` abs(_ )` free function"

ios - 为什么 XMPP 函数什么都不返回?