0

I am trying to move my collection view vertically 5px at a time using content offset using time interval trigger but it's not animating, my code for that is

timer = Timer.init(timeInterval: 1.0, target: self, selector: #selector(animateScroll), userInfo: nil, repeats: true)

@objc func animateScroll() {
    self.previousOffset = self.collectionView.contentOffset.y
    self.collectionView.contentOffset.y = self.previousOffset + 5
}
  • 1
    Possible duplicate of [How to properly animate UIScrollView contentOffset](https://stackoverflow.com/questions/21749950/how-to-properly-animate-uiscrollview-contentoffset) – Devil Decoder Jul 02 '18 at 12:17

1 Answers1

2

just use method setContentOffset:animated:

Yaroslav Luchyt
  • 223
  • 3
  • 8