Thursday, October 29, 2026
HomeiOS Developmentios - Lottie Animation glitching in UIRefreshControl subview in Swift

ios – Lottie Animation glitching in UIRefreshControl subview in Swift

[ad_1]

I’m making an attempt to load a Lottie animation within the subview of scrollview.refreshControl, the animation seems on the pull to refresh however is glitching which makes the animation look not easy and seems to be very buggy.

the code that I’m utilizing 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, motion: #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.primary.bounds.width/2).isActive = true
    loadingView.heightAnchor.constraint(equalToConstant: 50).isActive = true

the glitchy loader

This solely happens on lottie animation, the default activityIndicator seems to be animating easily.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments