I want to do the following behavior: on VC (in viewDidAppear) there is a scrollView with a content size of 2 screens, I want to start scrolling to the bottom offset which can be stopped by swiping and immediately start scrolling without lifting your hand.
Scroll launch code:
let bottomOffset = CGPoint(x: 0,
y: scrollView.contentSize.height - scrollView.bounds.height)
UIView.animate(withDuration: 7, delay: 0.0, options: [.curveLinear]) {
self.scrollView.setContentOffset(bottomOffset, animated: false)
}
The scroll starts successfully, but it is impossible to stop it until the animation is completed.
I tried to add a view after the animation starts on top of the scroll and hide it when the animation is finished. This view can intercept the swipe and do:
self.scrollView.layer.removeAllAnimations()
But this action only stops the animation and immediately throws me onto the bottomOffset. I don’t understand how I can stop the animation in a certain place and immediately pass the swipe to the scrolling view and start scrolling it.
I’d be grateful for any ideas
Artem T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.