Search code examples
iosswiftlottie

Lottie with user interaction on iOS


In my iOS app I have lottie animation, which is on the whole screen. During animation user interactions are not available. I want to make everything under animation active to user interaction (scroll, buttons, etc.) Is there any chance to do it?

CODE:

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()
}

Solution

  • I bet disabling user interaction for the animation view would do the trick. Try something like: animationView.userInteractionEnabled = false. This should prevent touches from being consumed by the animationView and not being propagated down the view hierarchy.