Latest 0.1.8
License MIT
Platforms ios 9.3

CI Status
[Swift Version]()


Vertical Infinite Scroll Layout


Horizontal Infinite Scroll Layout



General initialization

UICollectionViewGallery has been implemented as UICollectionView extensions, all public functions are
accesible thru UICollectionView class instances.So basicly you need an instance of UICollectionView, which
can be created programaticly or via Storyboard.

import UICollectionViewGallery

    @IBOutlet weak var galleryCollectionView: UICollectionView!

Basic usage

You can setup the basic UICollectionViewGallery with fallowing function and this propertis: GalleryFlowStyle which represents the enum for different styles, minLineSpacing represents space between cells, itemSize represents size of the cells, minScaleFactor represents scaling factor between the center cell and the rest of the visible cells.

galleryCollectionView.setGallery(withStyle: .autoDynamic, minLineSpacing: 10, itemSize: CGSize(width: 200, height: 200),minScaleFactor:0.6)

Note that this general approuch sets up the same cell properties for both Vertical and Horizontal flow layouts,howover if you need a more custom approuch you can setup both flow layout seperatly thru the fallowing methods.

galleryCollectionView.setGallery(forLayout: .vertical, minLineSpacing: 10, itemSize: CGSize(width: 200, height:200), minScaleFactor: 0.5)
galleryCollectionView.setGallery(forLayout: .horizontal, minLineSpacing: 20, itemSize: CGSize(width: 300, height:300), minScaleFactor: 0.8)
galleryCollectionView.setGalleryWithCustomFlows(andStyle: .autoDynamic)


You can disable infinite scroll and scaling by calling the fallowing function,they are enabled by default.

galleryCollectionView.setGaleryBehavior(forInfiniteScroll: false, andScalingElemnts: false)

Supported Styles

public enum GalleryFlowStyle {
    case vertical         // vertical flow
    case horizontal       // horizontal flow
    case autoFixed        // flow based on initial aspeciRatio  eg. height > width = Vertical, 
                          //                                        heignt < width = Horizontal
    case autoDynamic      // auto flow based on dynamic aspect ratio: requares orientation change event to be catched   

Final Touches

For infinite scroll and .autoDynamic style support, you have to handle properly 2 events, and call the appropriate functions.

 func scrollViewDidScroll(_ scrollView: UIScrollView) {
  override func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {

Aditional methods

You can find the indexPath for the center element by using the fallowing UICollectionView extension public property centerCellIndexPath


which retunrs an optional indexPath for the center element of the CollectionView


To run the example project, clone the repo, and run pod install from the Example directory first.


  • iOS 9.+
  • Xcode 9.0+
  • Swift 4.0+


UICollectionViewGallery is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "UICollectionViewGallery"


ro6lyo, [email protected]


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

Latest podspec

    "name": "UICollectionViewGallery",
    "version": "0.1.8",
    "summary": "highly customizable uicollectionview gallery",
    "description": "longed description will be added later this is testing pod",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "ro6lyo": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.8"
    "platforms": {
        "ios": "9.3"
    "source_files": "UICollectionViewGallery/Classes/**/*",
    "pushed_with_swift_version": "4.0"

Pin It on Pinterest

Share This