I'm making a simple app testing Lottie animation library in swift. The code is perfectly running when i lunch the app for the first time. But if i relaunch it from the background, the animation stops.
How do i keep the animation running in the background so when i switch to another app and back again, i see the animation working.
I just started learning swift, so i apologize in advance.
import UIKit
import Lottie
class ViewController: UIViewController {
@IBOutlet weak var animationView: AnimationView!
override func viewDidLoad() {
super.viewDidLoad()
SetupAnimation()
}
func SetupAnimation() {
let animationView = AnimationView(name: "kiss")
animationView.frame = self.animationView.frame
self.animationView.addSubview(animationView)
animationView.loopMode = .autoReverse
animationView.contentMode = .scaleAspectFit
animationView.play()
}
}