A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎑 written in Swift

Overview

CenteredCollectionView

Build Status Version Carthage compatible SwiftPM compatible Swift 5.0 Platform

CenteredCollectionView is a lightweight drop in place UICollectionViewFlowLayout that pages and keeps its cells centered, resulting in the "carousel effect" 🎑

Example

Demo

To try the example using Cocoapods:

pod try CenteredCollectionView

Requirements

This pod requires a deployment target of iOS 9.0 or greater

Installation

CenteredCollectionView is available through Swift Package Manager, CocoaPods and Carthage.

To install it with Swift Package Manager, add the URL https://github.com/BenEmdon/CenteredCollectionView in Xcode Add Package Dependency assistant ; or add to your own Package.swift:

dependencies: [
  .package(url: "https://github.com/BenEmdon/CenteredCollectionView", from: "2.2.2")
]

To install it with Cocoapods, add the following line to your Podfile:

pod "CenteredCollectionView"

To install it with Carthage, add the following line to your Cartfile:

github "BenEmdon/CenteredCollectionView"

Usage

Checkout USAGE.md

API

Checkout API.md

Contributing

Have a suggestion? All contributions are welcome!

If you make a pull request or an issue, you're likely to get a swift response!

Author

@BenEmdon πŸ‘¨β€πŸ’»

License

CenteredCollectionView is available under the MIT license. See the LICENSE file for more info.

Comments
  •  First cell not centered before touch (iOS 13)

    First cell not centered before touch (iOS 13)

    Describe the bug The collection is not vertically centered correctly when the view appears. The collection centers itself once I touch it (slide).

    To Reproduce Steps to reproduce the behavior:

    1. Installa Catalina and Xcode Version 11.0 beta 5
    2. Use pod try CenteredCollectionView
    3. Run project
    4. Try programmatic or storyboard examples

    Expected behavior Vertically centered collection view

    Screenshots

    Before Slide:

    After slide:

    Smartphone

    • Device: iPhone Xs Simulator
    • OS: 13.0
    • Version beta

    Additional context This bug only occurs on the beta version of iOS 13. (iPhone Xs Simulator 13.0). Everything is fine with iOS 12.

    bug help wanted stale crypto reward πŸ’° 
    opened by dannyalbuquerque 13
  • How to integrate this pod with Storyboard?

    How to integrate this pod with Storyboard?

    So I have been working around with this pod for a day by now. I wanted the UI really bad for my collection view. I tried giving my collection view on my storyboard the CenteredCollectionView class after pod install but nope. That did not work. If you don't mind sharing how to make this work with Storyboard, it will make a world of a difference. Thanks.

    question 
    opened by jayvenn 7
  • Support iOS 13

    Support iOS 13

    Right now it appears that CenteredCollectionView doesn't support iOS 13 (ref #53). If anyone in the community of users would like to spare a hand, I would be more than happy to review and merge the code to make CenteredCollectionView support iOS 13.

    I'll buy the person that upgrades this some coffee (via a crypto transfer).

    I am also looking for a co-maintainer, if anyone is interested πŸ‘€

    help wanted crypto reward πŸ’° 
    opened by BenEmdon 6
  • Storyboard integration example

    Storyboard integration example

    It would nice to have an example to show how to integrate this framework with storyboards. Since storyboards are very popular it would be very beneficial for the future of this project.

    I hope to get around to this at some point but am very busy, so if someone in the community could lend a hand it would be greatly appreciated.

    enhancement 
    opened by BenEmdon 5
  • Why is this line needed?

    Why is this line needed?

    https://github.com/BenEmdon/CenteredCollectionView/blob/f2bf371dae314b46f1bc03c222861c9fc40fff32/CenteredCollectionView/Classes/CenteredCollectionViewFlowLayout.swift#L114

    Hi, nice library you have there. I've been wondering what is the use of that check here? it seems to be checking if the new offset doesn't lie within the natural bounds, and handle that. But isn't this already solved by the default bouncing behavior? I commented out that check, and the demo worked fine.

    question stale 
    opened by ahmedk92 4
  • Convert to Swift 4.2

    Convert to Swift 4.2

    When using the pod, Xcode gives a warning that the project isn't Swift 4.2. I tested the automatic converter of Xcode, and it looks like everything would still work. So probably a very minor change. screenshot 2018-11-25 at 19 17 17

    help wanted 
    opened by UsefulJeroen 4
  • Cell not centered

    Cell not centered

    Describe the bug The cell is not in center, but if i scroll the collection manuallt, the cell stops at center. Please check image.

    Expected behavior Cell should initially appear in center

    Screenshots

    img_0056 img_0057

    opened by ChitvanSaxena 4
  • Support Swift Package Manager

    Support Swift Package Manager

    Is your feature request related to a problem? Please describe. Xcode 11 enabled SPM to be used as a dependency manager. Since then, SPM support for libraries would be nice ; especially for One-Class libraries like this one :)

    Describe the solution you'd like Create a Package.swift file ; to enable SPM support

    Describe alternatives you've considered Cocoapods & Carthage are nice, but they feel heavy for small projects

    Additional context If I have spare time in the next few days, I'll submit a tested PR myself ; I could use this nice minimalist lib for a side project I wanna start ;)

    opened by Dean151 3
  • Is it possible to start the collectionView first cell at the beginning of the list and not centred ?

    Is it possible to start the collectionView first cell at the beginning of the list and not centred ?

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    opened by AlaeddineOuerteni 3
  • How to scale cells?

    How to scale cells?

    Hey! I'm not good at flow layout, please help me with my task. I need something like that: default So I need to scale cells where user scroll the collectionView. How can I do that, through edit your layout? Thanks!

    help wanted question stale 
    opened by Banck 3
  • didChangeCenteredPage ?

    didChangeCenteredPage ?

    Is there anyway to implement a function like didChangeCenteredPage() or something?

    I have animations occurring in each of my Collection View Cells but only want the animation to happen when the Cell becomes centered.

    Thanks for your help -Alex

    question 
    opened by 16alexanders 3
Releases(2.2.2)
Owner
Ben Emdon
Making GitHub's command palette 🎨
Ben Emdon
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022
BouncyLayout is a collection view layout that makes your cells bounce.

BouncyLayout is a collection view layout that makes your cells bounce. Features Pure Swift 5. Works with every UICollectionView. Horizontal and vertic

Robert-Hein Hooijmans 4.2k Jan 3, 2023
A mosaic collection view layout inspired by Lightbox's Algorithm, written in Swift πŸ”Ά

TRMosaicLayout A mosaic collection view layout inspired by Lightbox's Algorithm. This is a swift implementation/extension of @fmitech's FMMosaicLayout

Vincent Le 252 Nov 23, 2022
A bunch of layouts providing light and seamless experiences in your Collection View

Swinflate Description Swinflate aims to encorporate a set of collection view layouts which provide a better and even more fluid experience in collecti

Vlad Iacob 224 Dec 19, 2022
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎑 written in Swift

CenteredCollectionView CenteredCollectionView is a lightweight drop in place UICollectionViewFlowLayout that pages and keeps its cells centered, resul

Ben Emdon 1.2k Dec 6, 2022
Swipe between pages with an interactive title navigation control. Configure horizontal or vertical chains for unlimited pages amount.

SlideController is a simple and flexible UI component fully written in Swift. Built using power of generic types, it is a nice alternative to UIPageVi

Touchlane 409 Dec 6, 2022
Swipe between pages with an interactive title navigation control. Configure horizontal or vertical chains for unlimited pages amount.

SlideController is a simple and flexible UI component fully written in Swift. Built using power of generic types, it is a nice alternative to UIPageVi

Touchlane 411 Jan 5, 2023
A UICollectionViewLayout subclass displays its items as rows of items similar to the App Store Feature tab without a nested UITableView/UICollectionView hack.

CollectionViewShelfLayout A UICollectionViewLayout subclass displays its items as rows of items similar to the App Store Feature tab without a nested

Pitiphong Phongpattranont 374 Oct 22, 2022
Get notified about available COVID-19 vaccination appointments in Berlin's vaccination centers

VaccinationMonitor If you live in Berlin you might know how difficult it is to find an appointment to get a COVID-19 vaccination. This app notifies yo

Christian Lobach 8 Jan 14, 2022
Generate help centers for your iOS apps, with Markdown

Generate help centers for your iOS apps, with Markdown! All you need to do is wr

Peter Salz 6 Jan 15, 2022
An Integer type that clamps its value to its minimum and maximum instead of over- or underflowing.

ClampedInteger An Integer type that clamps its value to its minimum and maximum instead of over- or underflowing. Examples let big = ClampedIntege

Berik Visschers 0 Jan 17, 2022
Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)

AEAccordion UITableViewController with accordion effect (expand / collapse cells) Simple and lightweight solution for making accordion effect in table

Marko Tadić 211 Apr 18, 2022
UIView subclass that bends its edges when its position changes.

AHKBendableView BendableView is a UIView subclass that bends its edges when its position change is animated. Internally, BendableView contains CAShape

Arek Holko 591 Jul 24, 2022
A UISwitch that infects its superview with its tint color.

UISwitch subclass that 'infects' the parent view with the onTintColor when the switch is turned on. Inspired by this Dribble by Ramotion. Screenshot I

Andrea Mazzini 337 Sep 12, 2022
A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.

AnimatedCollectionViewLayout Normally a UICollectionView has no transition effects when you scroll from one item to another. There are lots of ways to

Jin Wang 4.5k Jan 1, 2023
sample project for `UICollectionViewLayout` implementation

collection-view-layout-pattern-sample UICollectionViewLayout implementation pattern. About This project is introduced in iOSDC Japan 2021. sample code

Toshiki Takezawa 13 Nov 3, 2021
An extandable mosaic UICollectionViewLayout with a focus on extremely flexible customizations :large_orange_diamond:

SquareMosaicLayout An extandable mosaic UICollectionViewLayout with a focus on extremely flexible customizations. Note This layout is not of waterfall

Mikhail Vasilev 254 Dec 6, 2022
UICollectionViewLayout with focused content

SFFocusViewLayout Overview SFFocusViewLayout is a UICollectionViewLayout subclass for displaying focused content on UICollectionView which is the larg

Sergio FernΓ‘ndez 1.8k Dec 28, 2022
A cells of UITableView can be rearranged by drag and drop.

TableViewDragger This is a demo that uses a TableViewDragger. Appetize's Demo Requirements Swift 4.2 iOS 8.0 or later How to Install TableViewDragger

Kyohei Ito 515 Dec 28, 2022
A Swift library for swipeable table cells

BWSwipeRevealCell Using the library **Note: Use version 1.0.1 for Swift 2.3 support and version 2.0.0 or higher for Swift 3 support ** There are two m

Kyle Newsome 67 May 11, 2022