Search code examples
uiviewuiviewanimationuser-interaction

iOS:Multiple UIView Animation issue


I am facing the problem in UIViewAnimation because of user interaction (continuous scrolling on collection view. As user scroll the collection view, RED line in below image is freezing(not moving forward). When the user stop collection scrolling line is moving.

Note: For line movement, I am using the UIViewAnimation. Observation: I am considering the when user scrolling collection view this operation is performing on the main queue that's why RED line is freezing.

How to avoid this blocker?. I want the user to scroll the collection view continuously without freezing the RED line.

enter image description here


Solution

  • **

    Finally, i solved above problem by adding animation timer in run loop.
    e.g 
    func updateLine() {
    //line animation code goes here.
    }
    
    let animationTimer = Timer.scheduleTimer(timerInterval: 1, target: self, selector: #selector(self.updateLine), userInfo: nil, repeats: true)
    
    RunLoop.current.add(animationTimer, forMode: RunloopMode.UITrackingRunLoopMode)
    that's it
    

    **