在uiCollectionview的每个部分制作不同的滚动条

时间:2017-11-19 21:15:54

标签: swift scroll uicollectionview

我想在第一部分进行水平滚动,在collectionView的第二部分进行垂直滚动。我使用collectionviewlayout但我还不能!

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        if indexPath.section == 0 {

            if let layout = myCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
                layout.scrollDirection = .horizontal
            }
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell1", for: indexPath) as! CategoryCollectionViewCell

            return cell
        } else {
            if let layout = myCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
                layout.scrollDirection = .vertical
            }

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

            return cell
        }
    }

我正在使用 swift 4 我不想将嵌套的集合视图一起使用或与tableViews一起使用!!

0 个答案:

没有答案