I have a UIScrollView that lays out a grid of icons. If you were to imagine the layout for the iOS Springboard, you'd be pretty close to correct. It has a horizontal, paged scroll (just like Springboard). However, it appears that the layout is not quite right. It appears as though it is laying out the items from top to bottom. As a result, my last column only has 2 rows in it, due to the number of items to be displayed. I'd rather have my last row on the last page have 2 items, like you would see in the Springboard.
How can this be accomplished with UICollectionView and its related classes? Do I have to write a custom UICollectionViewFlowLayout?
This code works well in Swift 3.1 and Xcode 8.3.2
From @Erik Hunter, I post full code for make horizontal
UICollectionView
In Swift
In Swift 3.0
Hope this help
for xcode 8 i did this and it worked:![](https://i.stack.imgur.com/gE9Xs.png)
I am working on Xcode 6.2 and for horizontal scrolling I have changed scroll direction in attribute inspector.
click on collectionView->attribute inspector->scroll Direction->change to horizontal
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 thenumberOfItems
you have returned in its datasource implementation.