Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uicollectionview 如何像swift 4 ios中底部的新闻代码一样平滑地滚动collectionViewCell_Uicollectionview_Swift4_Horizontal Scrolling_Smooth Scrolling_Marquee - Fatal编程技术网

Uicollectionview 如何像swift 4 ios中底部的新闻代码一样平滑地滚动collectionViewCell

Uicollectionview 如何像swift 4 ios中底部的新闻代码一样平滑地滚动collectionViewCell,uicollectionview,swift4,horizontal-scrolling,smooth-scrolling,marquee,Uicollectionview,Swift4,Horizontal Scrolling,Smooth Scrolling,Marquee,我想慢慢地、平滑地、自动地滚动collectionView单元格,就像swift 4中的字幕一样 试着用这个来制作动画,效果会很好 func startScrolling(){ let co = collectionView.contentOffset.x let no = co + 1 UIView.animate(withDuration: 0.001, delay: 0, options: .curveEaseInOut,

我想慢慢地、平滑地、自动地滚动collectionView单元格,就像swift 4中的字幕一样

试着用这个来制作动画,效果会很好

func startScrolling(){
       let co = collectionView.contentOffset.x            
       let no = co + 1
        UIView.animate(withDuration: 0.001, delay: 0, options: .curveEaseInOut, animations: { [weak self]() -> Void in
               self?.collectionView.contentOffset = CGPoint(x: no, y: 0)
               }) { [weak self](finished) -> Void in
                   self?.startScrolling()
                 }
            } 

但是从这个“无法获取索引”和“无法单击”,需要帮助吗

我认为当你与collectionview交互时,你必须停止动画我认为当你与collectionview交互时,你必须停止动画