I am trying to load a Lottie animation in the subview of scrollview.refreshControl, the animation appears on the pull to refresh but is glitching which makes the animation look not smooth and appears to be very buggy.
the code that I am using in viewDidLoad:
let loadingView : AnimationView = {
let view = AnimationView()
view.translatesAutoresizingMaskIntoConstraints = false
view.animation = Animation.named("loading-dots-blue")
view.loopMode = .loop
view.contentMode = .scaleAspectFill
view.play()
return view
}()
scrollView.refreshControl = UIRefreshControl()
scrollView.refreshControl?.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
scrollView.refreshControl!.addSubview(loadingView)
scrollView.refreshControl?.tintColor = .clear
loadingView.centerXAnchor.constraint(equalTo: scrollView.refreshControl!.centerXAnchor).isActive = true
loadingView.centerYAnchor.constraint(equalTo: scrollView.refreshControl!.centerYAnchor).isActive = true
loadingView.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width/2).isActive = true
loadingView.heightAnchor.constraint(equalToConstant: 50).isActive = true
This only occurs on lottie animation, the default activityIndicator appears to be animating smoothly.