How to change UICollectionView Scroll Direction?

前端 未结 2 1102
我在风中等你
我在风中等你 2021-02-01 02:20

I have successfully implemented a UICollectionView. Is it possible to change the scrollDirection?

Can you please show how to implement it pro

2条回答
  •  甜味超标
    2021-02-01 02:59

    if you did not use storyboard and all is done with programmatically. so when we do that like this:

      lazy var snapCollectionView: UICollectionView = {
            let layout = UICollectionViewFlowLayout()
            let collectionView = UICollectionView(frame: CGRect.zero, 
            collectionViewLayout: layout)
            layout.scrollDirection = .horizontal
            collectionView.delegate = self
            collectionView.dataSource = self
            collectionView.backgroundColor = UIColor(named: "background")
            return collectionView
        }()
    

提交回复
热议问题