GitHub - netguru/CarLensCollectionViewLayout: An easy-to-use Collection View Lay...
source link: https://github.com/netguru/CarLensCollectionViewLayout
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
CarLensCollectionViewLayout
An easy-to-use Collection View Layout for card-like animation ?
CarLensCollectionViewLayout was created out of the implementation in CarLens application ?. The image above exactly shows the screen from the app!
Requirements
CarLensCollectionViewLayout is written in Swift 4.2 and supports iOS 9.0+.
Usage
Basic Usage
The two main steps are needed for the configuration of CarLensCollectionViewLayout:
Step 1
Assign CarLensCollectionViewLayout
to yours collection view layout:
collectionView.collectionViewLayout = CarLensCollectionViewLayout()
or initialize your collection view with CarLensCollectionViewLayout
:
UICollectionView(frame: .zero, collectionViewLayout: CarLensCollectionViewLayout())
Step 2
Subsclass CarLensCollectionViewCell
and call configure(topView: UIView, cardView: UIView)
right on the start!
class CollectionViewCell: CarLensCollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) configure(topView: upperView, cardView: bottomView) } }
The sample implementation is available in Demo project.
Customization
Layout
You can also initialize CarLensCollectionViewLayout
with a CarLensCollectionViewLayoutOptions
object by passing any of the parameters available. Others will be configured automatically.
Parameters:
minimumSpacing
- A minimum spacing between cells.
decelerationRate
- A deceleration for a scroll view.
shouldShowScrollIndicator
- A value indicating whether collection view should have a scroll indicator.
itemSize
- The size to use for cells.
Example:
let options = CarLensCollectionViewLayoutOptions(minimumSpacing: 40) collectionView.collectionViewLayout = CarLensCollectionViewLayout(options: options)
Cell
While subsclassing CarLensCollectionViewCell
you can call configure(...)
with an additional parameter topViewHeight
. The card view height will be calculated based on this value.
Example:
class CollectionViewCell: CarLensCollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) configure(topView: upperView, cardView: bottomView, topViewHeight: 300) } }
Installation
CocoaPods
If you're using CocoaPods, add the following dependency to your Podfile
:
use_frameworks!
pod 'CarLensCollectionViewLayout', '~> 1.1.0'
Carthage
If you're using Carthage, add the following dependency to your Cartfile
:
github "netguru/CarLensCollectionViewLayout" ~> 1.1.0
About
This project is made with ❤️ by Netguru.
License
CarLensCollectionViewLayout is licensed under the MIT License. See LICENSE.md for more info.
Related links
Recommend
-
37
Sneaky Bugs and How to Find Them (with git bisect)
-
50
With this tutorial you can learn how to use Kotlin range expressions to iterate through progressions of non-primitive, Comparable types. It also presents how to use range expressions in control flow statements.
-
53
5 Git commands I wish I knew about when I started coding - Must know GIT commands.
-
42
The Collection View provides a flexible way to present content to the user. Similar to a table view, a collection view gets data from custom data source objects and displays it using a combination of cell, layout, and sup...
-
9
Android View Binding or Data Binding? [2 easy use cases]That question has certainly outlived its time in android development. With Kotlin synthetics deprecated now is also gaining popularity. Ever since Data Bindings introduction dev...
-
16
Easy way to detect a retain cycle in a view controller 16 Jun 2020 ⋅ 2 min read ⋅ Xcode
-
4
Get an easy view of hard-to-reach places with the Sinji BorescopeThis iPho...
-
37
Table and Collection View Cells Reload Improvements in iOS 15 In October 2020, I published an article that discusses how to reload a table and collection vie...
-
4
How to Find All Fully Visible Cells in Table and Collection View Imagine you are given a task to find out which table view cells that are currently fully visible on screen. So you fire up Xcode, access the
-
6
Making CSS View Transitions Easy with Velvette Learn how to effortlessly implement smooth CSS view-transitions with Velvette, a useful library designed to tackle common challenges and enhance user experiences...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK