首页 > 解决方案 > Lottie 与 iOS 上的用户交互

问题描述

在我的 iOS 应用程序中,我有乐天动画,它在整个屏幕上。在动画期间,用户交互不可用。我想让动画下的所有内容都对用户交互(滚动、按钮等)处于活动状态。有没有机会做到这一点?

代码:

guard let mainView = self?.view, let animationView = LOTAnimationView(name: "someName") else { return }

animationView.frame = CGRect(x: 0,
                             y: 0,
                         width: mainView.frame.size.width,
                        height: mainView.frame.size.height)

animationView.contentMode = .scaleAspectFill
animationView.loopAnimation = false

mainView.addSubview(animationView)

animationView.play() { _ in
    animationView.removeFromSuperview()
}

标签: iosswiftlottie

解决方案


我敢打赌,禁用动画视图的用户交互就可以了。尝试类似: animationView.userInteractionEnabled = false。这应该防止触摸被 消耗animationView并且不会被向下传播到视图层次结构中。


推荐阅读