FlowLayout for UICollectionView to represent cells as a list with additional click animation or loading state
1.0.0
ListFlowLayout support Swift Package Manager.
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "ListFlowLayout",
platforms: [
.iOS(.v12),
],
dependencies: [
.package(name: "ListFlowLayout", url: "https://github.com/mark-kebo/ListFlowLayout", from: "1.0.0")
],
targets: [
.target(name: "YourTestProject", dependencies: ["ListFlowLayout"])
]
)
And then import wherever needed: import ListFlowLayout
- Using Xcode 11 go to File > Swift Packages > Add Package Dependency
- Paste the project URL: https://github.com/mark-kebo/ListFlowLayout
- Click on next and select the project target
- Don't forget to set
DEAD_CODE_STRIPPING = NO
in yourBuild Settings
(https://bugs.swift.org/plugins/servlet/mobile#issue/SR-11564)
If you have doubts, please, check the following links:
After successfully retrieved the package and added it to your project, just import ListFlowLayout
and you can get the full benefits of it.
import ListFlowLayout
final class YourCollectionViewCell: ListCollectionViewCell {
override func awakeFromNib() {
super.awakeFromNib()
self.highlitedStyle = .background(UIColor.lightGray)
self.isLoadingIndicatorStarted = true
}
}
final class YourViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
let customFlowLayout = ListFlowLayout(cellSideInset: 8)
collectionView.collectionViewLayout = customFlowLayout
collectionView.contentInsetAdjustmentBehavior = .always
collectionView.dataSource = self
collectionView.delegate = self
}
}