Я пытаюсь использовать файлы lottie в своем проекте, я много раз пытался, чтобы никто не работал.ничего не отображается мой код ниже я попробовал два способа 1- lottieAnimation()
, 2- `setupAnimation () также я попробовал через UIView, я хочу, чтобы ваша помощь знала, в чем проблема, и сделайте правильные шаги для ее успешного использования.
import UIKit
import Lottie
class BonusVC: UIViewController {
@IBOutlet weak var containerAnim: UIView!
var animation : AnimationView?
let animationView = AnimationView()
override func viewDidLoad() {
super.viewDidLoad()
lottieAnimation()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
lottieAnimation()
//setupAnimation()
}
func setupAnimation() {
animation = AnimationView(name: "wallet")
animation?.frame = self.containerAnim.frame
self.containerAnim.addSubview(animation!)
animation?.loopMode = .autoReverse
animation?.contentMode = .scaleAspectFit
animation?.play()
}
func lottieAnimation() {
let animation = Animation.named("wifi", subdirectory: "LottieAnimation")
animationView.animation = animation
animationView.contentMode = .scaleAspectFit
view.addSubview(animationView)
animationView.backgroundBehavior = .pauseAndRestore
animationView.translatesAutoresizingMaskIntoConstraints = false
animationView.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor).isActive = true
animationView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
animationView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -12).isActive = true
animationView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
animationView.setContentCompressionResistancePriority(.fittingSizeLevel, for: .horizontal)
animationView.play()
}
}