首页 > 解决方案 > 如何在 swift 4 ios 中像新闻行情一样平滑滚动 collectionViewCell

问题描述

我想像 swift 4 中的选框一样缓慢、平滑、自动地滚动 collectionView 单元格。

尝试用它制作动画并完美运行

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()
                 }
            } 

但从此无法获取索引,也无法点击,需要帮助

标签: uicollectionviewswift4horizontal-scrollingsmooth-scrollingmarquee

解决方案


推荐阅读