0

this is my Viewcontroller

 class ViewController: UIViewController {

        var index = 0
        @IBOutlet weak var lottieView: UIView!
        fileprivate let lottieTouchIdAnimationName = "01_touchId_validation"
        fileprivate let lottieFaceIdAnimationName = "01_faceId_validation"
         @IBOutlet weak var label: UILabel!
        var onBoardingCompletionBlock: ((Bool, Bool?) -> Void)?
        var authenticationResponse: Bool!


        override func viewDidLoad() {
            super.viewDidLoad()

            setupView()
        }


        func setupView() {

            var animationName = ""
            switch index {
            case 0:
                animationName = lottieFaceIdAnimationName
                label.text = "anim 0"
            default:
                animationName = lottieTouchIdAnimationName
                label.text = "anim 1"
            }

            _ = LottieView(in: lottieView,
                           bundle: Bundle.main,
                           name: animationName,
                           velocity: 1.0,
                           loop: false) {[unowned self] _ in
                            self.animationEnded()
            }
        }
        func animationEnded() {
            if let onBoardingCompletionBlock = onBoardingCompletionBlock {
                onBoardingCompletionBlock(true, self.authenticationResponse)
                dismiss(animated: true, completion: nil)
            } else {

            }
        }
    }

the storyboard with all the outlets connected:

enter image description here

I have the pod installed and the assets are all available in XCAssets

a.masri
  • 2,439
  • 1
  • 14
  • 32

1 Answers1

2

Try this:

class HmePaymentStatusVC: UIViewController {
    var animationView = LOTAnimationView(name: "lottie_animation_file")

    override func viewDidLoad() {
        super.viewDidLoad()
        animate()
    }

    func animate() {
        animationView.frame = view.bounds
        animationView.contentMode = .scaleAspectFit
        animationView.animationSpeed = 0.5
        self.view.addSubview(animationView)
        animView.play()
    }
}
Pang
  • 9,564
  • 146
  • 81
  • 122