VerticalFlowLayout
This implementation is built using a UICollectionView and a custom flowLayout.
Table of contents
Requirements
- iOS 11.0+
 - Swift 5
 
Installation
CocoaPods
Add Instructions to your Podfile:
pod 'VerticalFlowLayout'
Then, run the following command:
$ pod install
Swift Package Manager
In Xcode, use File > Swift Packages > Add Package Dependency and use https://github.com/rastaman111/VerticalFlowLayout.
Carthage
To install with Carthage, simply add the following line to your Podfile:
github "rastaman111/VerticalFlowLayout"
Manually
If you prefer not to use any of dependency managers, you can integrate manually. Put Sources/VerticalFlowLayout folder in your Xcode project. Make sure to enable Copy items if needed and Create groups.
Usage
To use VerticalFlowLayout inside your UIViewController:
import VerticalFlowLayout
class ViewController: UIViewController, VerticalCollectionViewDelegate, VerticalCollectionViewDataSource {
    
    @IBOutlet var verticalView: VerticalView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        verticalView.delegate = self
        verticalView.datasource = self
        
        // register cell
        verticalView.register(nib: UINib(nibName: "ExampleCell", bundle: nil), forCellWithReuseIdentifier: "ExampleCell")
    }
    
    func cellForItemIn(verticalCollectionView: VerticalCollectionView, cellForItemAt indexPath: Int) -> UICollectionViewCell {
        let cell = verticalCollectionView.dequeueReusableCell(withReuseIdentifier: "ExampleCell", for: indexPath) as! ExampleCell
       
        return cell
    }
    
     func numberOfItemsIn(verticalCollectionView: VerticalCollectionView) -> Int {
        return 20
    }
    
    func didSelectCell(verticalCollectionView: VerticalCollectionView, indexPath: Int) {
        // Called when the user clicks on a cell.
    }
}
Additionally
Get current cell
The currently focussed cell index
verticalView.focussedCellIndex
Get a cell at a specified index
Returns the visible cell object at the specified index.
verticalView.cellForItem(at index: Int) -> UICollectionViewCell?
Scroll to a specifc cell
Scrolls the collection view contents until the specified item is visible
verticalView.scrollToCell(at: Int, animated: Bool) -> Bool
Moving cell
Moves an item from one location to another in the collection view.
verticalView.moveCell(at: Int, to: Int)
Deleting cells
Deletes cells at the specified indexes
verticalView.deleteCells(at: [Int])
Inserting cells
Inserts new cells at the specified indexes
verticalView.insertCells(at: [Int])
License
VerticalFlowLayout is available under the MIT license. See the LICENSE file for more info.

