{"id":16853131,"url":"https://github.com/devxoul/uicollectionviewflexlayout","last_synced_at":"2025-08-24T06:10:55.444Z","repository":{"id":56924803,"uuid":"99367789","full_name":"devxoul/UICollectionViewFlexLayout","owner":"devxoul","description":"A drop-in replacement for UICollectionViewFlowLayout","archived":false,"fork":false,"pushed_at":"2019-04-03T15:02:00.000Z","size":35,"stargazers_count":306,"open_issues_count":1,"forks_count":21,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-08-10T23:42:48.764Z","etag":null,"topics":["uicollectionview","uicollectionviewlayout"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devxoul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-04T17:58:55.000Z","updated_at":"2025-08-07T09:57:57.000Z","dependencies_parsed_at":"2022-08-21T05:20:37.541Z","dependency_job_id":null,"html_url":"https://github.com/devxoul/UICollectionViewFlexLayout","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/devxoul/UICollectionViewFlexLayout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FUICollectionViewFlexLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FUICollectionViewFlexLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FUICollectionViewFlexLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FUICollectionViewFlexLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devxoul","download_url":"https://codeload.github.com/devxoul/UICollectionViewFlexLayout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FUICollectionViewFlexLayout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271804342,"owners_count":24824644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["uicollectionview","uicollectionviewlayout"],"created_at":"2024-10-13T13:49:50.763Z","updated_at":"2025-08-24T06:10:55.373Z","avatar_url":"https://github.com/devxoul.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UICollectionViewFlexLayout\n\n![Swift](https://img.shields.io/badge/Swift-5.0-orange.svg)\n[![CocoaPods](http://img.shields.io/cocoapods/v/UICollectionViewFlexLayout.svg)](https://cocoapods.org/pods/UICollectionViewFlexLayout)\n[![Build Status](https://travis-ci.org/devxoul/UICollectionViewFlexLayout.svg?branch=master)](https://travis-ci.org/devxoul/UICollectionViewFlexLayout)\n[![Codecov](https://img.shields.io/codecov/c/github/devxoul/UICollectionViewFlexLayout.svg)](https://codecov.io/gh/devxoul/UICollectionViewFlexLayout)\n\nUICollectionViewFlexLayout is a drop-in replacement for UICollectionViewFlowLayout.\n\n## Features\n\n* [x] Section Spacing\n* [x] Section Margin\n* [x] Section Padding\n* [x] Section Background\n* [x] Item Spacing\n* [x] Item Margin\n* [x] Item Padding\n* [x] Item Size\n* [x] Item Background\n* [x] Item Z-Index\n\n## Basic Concept\n\nDon't let cells have margins and paddings. Cell metrics are now set outside of the cell. Just focus on contents.\n\n![idea](https://user-images.githubusercontent.com/931655/28981116-59c51f24-798b-11e7-8877-b4e7f83644d1.jpg)\n\n## Usage\n\n### UICollectionViewDelegateFlexLayout\n\n```swift\nprotocol UICollectionViewDelegateFlexLayout {\n  // section vertical spacing\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, verticalSpacingBetweenSectionAt section: Int, and nextSection: Int) -\u003e CGFloat\n\n  // section margin\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, marginForSectionAt section: Int) -\u003e UIEdgeInsets\n\n  // section padding\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, paddingForSectionAt section: Int) -\u003e UIEdgeInsets\n\n  // item horizontal spacing\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, horizontalSpacingBetweenItemAt indexPath: IndexPath, and nextIndexPath: IndexPath) -\u003e CGFloat\n\n  // item vertical spacing\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, verticalSpacingBetweenItemAt indexPath: IndexPath, and nextIndexPath: IndexPath) -\u003e CGFloat\n\n  // item margin\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, marginForItemAt indexPath: IndexPath) -\u003e UIEdgeInsets\n\n  // item padding\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, paddingForItemAt indexPath: IndexPath) -\u003e UIEdgeInsets\n\n  // item size\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, sizeForItemAt indexPath: IndexPath) -\u003e CGSize\n\n  // item z-index\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewFlexLayout, zIndexForItemAt indexPath: IndexPath) -\u003e Int\n}\n```\n\n### Section and Item Background\n\n```swift\n// register\ncollectionView.register(MySectionBackgroundView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionBackground, withReuseIdentifier: \"mySectionBackgroundView\")\ncollectionView.register(MyItemBackgroundView.self, forSupplementaryViewOfKind: UICollectionElementKindItemBackground, withReuseIdentifier: \"myItemBackgroundView\")\n\n// configure\nfunc collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -\u003e UICollectionReusableView {\n  switch kind {\n  case UICollectionElementKindSectionBackground: // section background\n    return collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionBackground, withReuseIdentifier: \"mySectionBackgroundView\", for: indexPath)\n\n  case UICollectionElementKindItemBackground: // item background\n    return collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindItemBackground, withReuseIdentifier: \"myItemBackgroundView\", for: indexPath)\n\n  case foo: // else\n    return bar\n  }\n}\n```\n\n## Tips and Tricks\n\n* **Using with RxCocoa**\n\n    If you're using UICollectionView with RxSwift and RxCocoa, you should create an extension of `_RXDelegateProxy` class to support delegate proxy.\n\n    ```swift\n    import RxCocoa\n    import UICollectionViewFlexLayout\n\n    extension _RXDelegateProxy: UICollectionViewDelegateFlexLayout {\n    }\n    ```\n\n## Contributing\n\n```console\n$ swift package generate-xcodeproj\n```\n\n## License\n\nUICollectionViewFlexLayout is under MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2Fuicollectionviewflexlayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevxoul%2Fuicollectionviewflexlayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2Fuicollectionviewflexlayout/lists"}