I have successfully implemented a UICollectionView
. Is it possible to change the scrollDirection
?
Can you please show how to implement it pro
This is how you create it in code with UICollectionViewFlowLayout
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
let collectionView = UICollectionView(frame: frame, collectionViewLayout: layout)
or if you are working with an existent collection view
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .vertical
}
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
}()