2

Now, I have lottie file animation for tabbar icon but I don't know how to put it when select tab to be animation view.

Has anyone can help me about this or just guide me? Thank you.

Nawin P.
  • 223
  • 1
  • 4
  • 11
  • 1
    I think this can help you https://stackoverflow.com/questions/3520049/uitabbaritem-icon-animation – stackich May 21 '21 at 08:03

1 Answers1

1

Create these function after importing Lottie:

func showLoadingAnimation(view: UIView) {
    animationView.isHidden = false
    animationView.animation = Animation.named("53175-ball-spinner")
    animationView.frame = CGRect(x: 0, y: 0, width: 80, height: 80)
    animationView.center = view.center
    animationView.contentMode = .scaleAspectFill
    animationView.loopMode = .loop
    animationView.play()
    view.addSubview(animationView)
}

func hideLoadingAnimation() {
    animationView.stop()
    animationView.isHidden = true
}

Call them where ever needed as:

showLoadingAnimation(view: self.view)