美文网首页
iOS无限轮播图

iOS无限轮播图

作者: CodingTom | 来源:发表于2021-08-19 21:42 被阅读0次
 open func scrollViewDidScroll(_ scrollView: UIScrollView) {
        var index = Float(scrollView.contentOffset.x * 1.0 / scrollView.frame.size.width)

        index = index.isNaN ? 0 : index

        if index < 0.25 {
            collectionView.scrollToItem(at: IndexPath(item: data.count, section: 0), at: [.top, .left], animated: false)
        } else if index >= Float(data.count + 1) {
            collectionView.scrollToItem(at: IndexPath(item: 1, section: 0), at: [.top, .left], animated: false)
        }

        let page = transferIndex(Int(index))

        scrollToPage(page)
        calculateParallax()
    }

https://hub.fastgit.org/vlondon/VMScrollView

相关文章

网友评论

      本文标题:iOS无限轮播图

      本文链接:https://www.haomeiwen.com/subject/ubzyvltx.html