UICollectionView subclass to easily setup a collection view with a given number of columns. Just so you know, it uses swizzling for these two methods of UICollectionViewDelegate:
collectionView(_:layout:sizeForItemAt:)
collectionView(_:layout:insetForSectionAt:)Just use CWCollectionView as a class for your collection view (from storyboard or code)
Make your VC implement CWCollectionViewDelegate
These methods need to be implemented:
func numberOfColumns() -> Int
func itemHeightRatio() -> CGFloat
func sectionInsets() -> UIEdgeInsets
func itemMinimumMargin() -> CGFloat
func headerHeight() -> CGSizeThen don't forget to set the cwDelegate property of your collectionView.
cwCollectionView.cwDelegate = selfClone the repo to see an exemple project
To run the example project, clone the repo, and run the xcodeproj
CWCollectionView is compatible for iOS versions > 9.0
CWCollectionView is written in swift 4.1
Just add the the following line for your target:
pod 'CWCollectionView'Then run
pod install Cwep, valentindenis80@gmail.com
MIT