I have successfully implemented a UICollectionView
. Is it possible to change the scrollDirection
?
Can you please show how to implement it programmatically?
You need to reduce the height of UICollectionView to its cell / item height and select " Horizontal " from the " Scroll Direction " as seen in the screenshot below. Then it will scroll horizontally depending on the numberOfItems you have returned in its datasource implementation.
A layout object that organizes items into a grid with optional header and footer views for each section.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With