Ios 无法设置收集单元格

Ios 无法设置收集单元格,ios,swift,uicollectionview,Ios,Swift,Uicollectionview,我想设置收集单元。一个永远是中心。和其他两个左上角的集合视图。我想知道中心项目的名称。最初,当数据加载时,第一个单元始终位于中心。请看图片。 这是我的尝试,但没有成功。请帮帮我或提出其他建议 extension AudioViewController : UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout{ func collectionView(_

我想设置收集单元。一个永远是中心。和其他两个左上角的集合视图。我想知道中心项目的名称。最初,当数据加载时,第一个单元始终位于中心。请看图片。

这是我的尝试,但没有成功。请帮帮我或提出其他建议

   extension AudioViewController : UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout{
        func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
            return 10
        }

        // make a cell for each cell index path
        func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

            // get a reference to our storyboard cell
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AudioCollectionViewCell", for: indexPath) as! AudioCollectionViewCell

 cell.backgeoundImage.image = UIImage(named :"play.png")

            return cell
        }

 *

    @objc(collectionView:layout:insetForSectionAtIndex:)  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets{
            return UIEdgeInsetsMake(0, 100, 0, 0)
        }

*

你目前的成绩如何?现在还不清楚,因为我们不知道单元格的大小(您是否覆盖了相应的布局委托方法?),如果是中心,您应该实现didcoll(或类似的)方法,该方法将为您提供当前的滚动偏移量(然后,通过简单的逻辑计算哪个在前面),还有一些关于在“分页”过程中提供一个小减速动画的问题。@Larme请帮助我简化一些代码片段:使用
indexPathsForVisibleItems
并计算中值!