如何在iOS中设置集合视图中内容偏移的动画?
我试图使用“内容偏移量”和“时间间隔触发器”一次垂直移动收藏视图5px,但它没有动画效果,我的代码就是这样如何在iOS中设置集合视图中内容偏移的动画?,ios,swift,Ios,Swift,我试图使用“内容偏移量”和“时间间隔触发器”一次垂直移动收藏视图5px,但它没有动画效果,我的代码就是这样 timer = Timer.init(timeInterval: 1.0, target: self, selector: #selector(animateScroll), userInfo: nil, repeats: true) @objc func animateScroll() { self.previousOffset = self.collectionView.co
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:
只需使用方法setContentOffset:animated:
可能重复的