Make different Scrolls on each section of uiCollectionview

Viewed 998

I wanna to make horizontal scroll on first section and vertical scroll on second section of collectionView. I used collectionviewlayout But I can't, yet!

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

I'm working with swift 4 and I don't want to use nested collectionviews together or with tableViews !!

0 Answers
Related