Bump version to 1.2.0
UICollectionViewFlexLayout is a drop-in replacement for UICollectionViewFlowLayout.
Don’t let cells have margins and paddings. Cell metrics are now set outside of the cell. Just focus on contents.
protocol UICollectionViewDelegateFlexLayout { // section vertical spacing func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, verticalSpacingBetweenSectionAt section: Int, and nextSection: Int) -> CGFloat // section margin func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, marginForSectionAt section: Int) -> UIEdgeInsets // section padding func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, paddingForSectionAt section: Int) -> UIEdgeInsets // item horizontal spacing func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, horizontalSpacingBetweenItemAt indexPath: IndexPath, and nextIndexPath: IndexPath) -> CGFloat // item vertical spacing func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, verticalSpacingBetweenItemAt indexPath: IndexPath, and nextIndexPath: IndexPath) -> CGFloat // item margin func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, marginForItemAt indexPath: IndexPath) -> UIEdgeInsets // item padding func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, paddingForItemAt indexPath: IndexPath) -> UIEdgeInsets // item size func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, sizeForItemAt indexPath: IndexPath) -> CGSize // item z-index func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, zIndexForItemAt indexPath: IndexPath) -> Int }
// register collectionView.register(MySectionBackgroundView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionBackground, withReuseIdentifier: "mySectionBackgroundView") collectionView.register(MyItemBackgroundView.self, forSupplementaryViewOfKind: UICollectionElementKindItemBackground, withReuseIdentifier: "myItemBackgroundView") // configure func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { switch kind { case UICollectionElementKindSectionBackground: // section background return collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionBackground, withReuseIdentifier: "mySectionBackgroundView", for: indexPath) case UICollectionElementKindItemBackground: // item background return collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindItemBackground, withReuseIdentifier: "myItemBackgroundView", for: indexPath) case foo: // else return bar } }
Using with RxCocoa
If you’re using UICollectionView with RxSwift and RxCocoa, you should create an extension of _RXDelegateProxy class to support delegate proxy.
_RXDelegateProxy
import RxCocoa import UICollectionViewFlexLayout extension _RXDelegateProxy: UICollectionViewDelegateFlexLayout { }
$ swift package generate-xcodeproj
UICollectionViewFlexLayout is under MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
UICollectionViewFlexLayout
UICollectionViewFlexLayout is a drop-in replacement for UICollectionViewFlowLayout.
Features
Basic Concept
Don’t let cells have margins and paddings. Cell metrics are now set outside of the cell. Just focus on contents.
Usage
UICollectionViewDelegateFlexLayout
Section and Item Background
Tips and Tricks
Using with RxCocoa
If you’re using UICollectionView with RxSwift and RxCocoa, you should create an extension of
_RXDelegateProxy
class to support delegate proxy.Contributing
License
UICollectionViewFlexLayout is under MIT license. See the LICENSE file for more info.