Introducing CarLensCollectionViewLayout - a New Open Source iOS Tool by Netguru
Usage
Why do we say that it’s easy to use? Well, because the basic usage consists of just two steps:
Step 1
Assigning CarLensCollectionViewLayout to your collection view layout:
collectionView.collectionViewLayout = CarLensCollectionViewLayout()
or initialising your collection view with CarLensCollectionViewLayout:
UICollectionView(frame: .zero, collectionViewLayout: CarLensCollectionViewLayout())
Step 2
Subsclassing CarLensCollectionViewCell and calling configure(topView: UIView, cardView: UIView) during the cell’s initialization:
class CollectionViewCell: CarLensCollectionViewCell {
override init(frame: CGRect) {
super.init(frame: frame)
configure(topView: upperView, cardView: bottomView)
}
}
We also provided a sample implementation, available in the CarLensCollectionViewLayout project.
Customization
We couldn’t leave you without some room for customization, of course! We created a struct called CarLensCollectionViewLayoutOptions, which allows you to configure spacing between cells, deceleration for the scroll view, scroll indicator visibility, and cell size.It’s also possible to set a custom top view height of the cell. The card view’s height will be calculated automatically based on that value.
The library can be added to your project with both CocoaPods and Carthage. All contributions are more than welcome! Feel free to create issues and PRs on the Github Repository. We made our app on Bitrise public so that anyone can see the results of its build logs. We would love to hear your feedback and thoughts!
There are more open source projects we’re working on right now – feel free to check them out! We'd love to meet you on Twitter too: @netguru.
Photo by Hal Gatewood on Unsplash