Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of type 'AnimationView?' has no member 'setAnimation'

Tags:

ios

swift

lottie

I am trying to add an animation to my application using Lottie but I get this error and I still do not know how to solve it.

import UIKit
import Lottie

class ViewController: UIViewController {
    @IBOutlet var animationView: AnimationView!

    override func viewDidLoad() {
        super.viewDidLoad()
        startAnimation()
    }
    
    func startAnimation(){
        animationView.setAnimation(named: "data")//error1
        animationView.loopAnimation = true//error2
        animationView.play()
    }
}

The error that comes out:

Value of type 'AnimationView?' has no member 'setAnimation'

Value of type 'AnimationView?' has no member 'loopAnimation'

enter image description here

like image 730
Josue Mejias Avatar asked May 29 '19 22:05

Josue Mejias


1 Answers

I'm using lottie-ios version 3.1.3 and ran into this same issue. After a little bit of digging I found that the syntax has changed. For your first error you need to change the code to the following:

animationView.animation = Animation.named("spineffectloader")

For the second error you should change the code to the following:

animationView.loopMode = .loop
like image 150
James Jordan Taylor Avatar answered Oct 07 '22 19:10

James Jordan Taylor