我试图使用时间间隔触发器使用内容偏移量一次垂直移动我的集合视图5px,但它不是动画,我的代码是
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
}
最佳答案
只需使用方法setContentOffset:animated:
关于ios - 如何在iOS的uicollectionview中设置contentoffset的动画?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51135882/