Ios 如何在swift中将集合视图转换为圆形icarousel

Ios 如何在swift中将集合视图转换为圆形icarousel,ios,swift,uicollectionview,icarousel,Ios,Swift,Uicollectionview,Icarousel,我想在集合视图中像在循环列表中一样显示单元格,这意味着在集合视图的最后一个单元格之后,在滚动集合视图时再次显示第一个单元格,像循环链接列表 我尝试过使用icrousel,但由于icarosuel只处理视图,我不想完整地完成集合视图,然后重新开始使用icarousel,所以有没有办法让我的集合视图循环 这是我的collectionViewcode func collectionView(_ collectionView: UICollectionView, ce

我想在集合视图中像在循环列表中一样显示单元格,这意味着在集合视图的最后一个单元格之后,在滚动集合视图时再次显示第一个单元格,像循环链接列表

我尝试过使用icrousel,但由于icarosuel只处理视图,我不想完整地完成集合视图,然后重新开始使用icarousel,所以有没有办法让我的集合视图循环

这是我的
collectionView
code

        func collectionView(_ collectionView: UICollectionView, 
         cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let cell = 
                collectionView.dequeueReusableCell(withReuseIdentifier: 
                "CellName", for: indexPath as IndexPath) as! CellName

        let gigModel = self.datasoruce?[indexPath.row]

        cell.lblTitle.text = gigModel?.title

        cell.btnPrice.setTitle(gigModel?.getPriceAccordingToGigType(), 
         for: .normal)

          cell.itemImageView.sd_setImage(with: URL(string: 
          (gigModel?.getPhotoPath())!), placeholderImage: 
          UIImage.init(named: "place_holder"))

        cell.itemImageView.layer.cornerRadius = 10.0

        if Utilities.isValidString(object: gigModel?.adminId as 
         AnyObject) {
            cell.btnStar.isHidden = false
        }
        else {
            cell.btnStar.isHidden = true
        }

        return cell
         }

我希望这是一个循环列表。

//使用下面的代码获取下一个单元格

func scrollToNextCell(){
    //get Collection View Instance
    let collectionView:UICollectionView;

    //get cell size
    let cellSize = CGSizeMake(self.view.frame.width, self.view.frame.height);

    //get current content Offset of the Collection view
    let contentOffset = collectionView.contentOffset;

    //scroll to next cell
    collectionView.scrollRectToVisible(CGRectMake(contentOffset.x + cellSize.width, contentOffset.y, cellSize.width, cellSize.height), animated: true);

}

//使用下面的代码获取下一个单元格

func scrollToNextCell(){
    //get Collection View Instance
    let collectionView:UICollectionView;

    //get cell size
    let cellSize = CGSizeMake(self.view.frame.width, self.view.frame.height);

    //get current content Offset of the Collection view
    let contentOffset = collectionView.contentOffset;

    //scroll to next cell
    collectionView.scrollRectToVisible(CGRectMake(contentOffset.x + cellSize.width, contentOffset.y, cellSize.width, cellSize.height), animated: true);

}

我尝试创建示例项目,它非常简单,下面是如何实现“无限”滚动的示例代码


希望它能帮助您

我尝试创建示例项目,它非常简单,下面是如何实现“无限”滚动的示例代码


希望它能帮助您

处理collectionView滚动,并替换基于collectionView的数组元素。我在理解这一点上有点困难,请您对此稍加说明。Thankshandle collectionView滚动条,并替换基于collectionView的数组元素。我理解这一点有点困难,请您对此稍加说明。谢谢你的关心,它正在工作。谢谢。谢谢你的关心,它正在工作。谢谢