0

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()
}
mag_zbc
  • 6,801
  • 14
  • 40
  • 62
Kamillpg
  • 1,303
  • 1
  • 9
  • 9

2 Answers2

4

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.

PanJanurz
  • 56
  • 1
  • 2
1

Did you tried adding gesture recognizers to Lottie view ?

Edit after code attach :

you can try add gestureRecognizer to animationView and add parameter (sender) on your function.

func handleTap(sender: UITapGestureRecognizer) {
    if sender.state == .ended {
        // handling code
    }
}
Arif Dogan
  • 35
  • 1
  • 8
  • Consider tableView under the animation. How to handle tap on cell? – Kamillpg Sep 14 '18 at 12:03
  • Shouldn't this be a comment instead of an answer? – ielyamani Sep 14 '18 at 12:16
  • Using gesture recognizer on animationView I can handle only tap on the animation. But what when I want to handle tap on one of hundred of buttons, tableviewCells, collectionViewCells under animation view? – Kamillpg Sep 14 '18 at 13:02