0

I'm currently trying to add a Lottie Animation to an UIView, which is located inside of an UIToolbar. It works fine when the animation is being called in viewDidLoad(). But calling animationView.play() inside of the view's bar button item action, won't work.

@IBOutlet var animationSubview: UIView!
let animationView = AnimationView(name: "hamburger")

func setupAnimation() {
        animationView.frame = CGRect(x: -33, y: -33, width: 120, height: 120)
        animationView.contentMode = .scaleAspectFill

        animationSubview.addSubview(animationView)
}

@IBAction func buttonHamburger(_ sender: Any) {
        animationView.play()
}

Is there mistake inside of my code or is an UIView inside of a toolbar just not working?

Tom
  • 3,672
  • 6
  • 20
  • 52

1 Answers1

0

Are you sure issue is in the call?

I had a similar problem(without animation)

Maybe your button does not receive taps because of Toolbar(or something else) cancel touches.

Ilya Stukalov
  • 101
  • 1
  • 3