Latest 0.1.4
Homepage https://github.com/facetdigital/QuiltView
License MIT
Platforms ios 10.2, tvos 10.1
Authors

A UICollectionViewLayout subclass, used as the layout object of a UICollectionView. QuiltView can be used with iOS and tvOS, is developed in Swift, and based on the Objective-C RFQuiltLayout library.

QuiltView is a Swift port of RFQuiltLayout, but not all features are necessarily ported and some additional features have been added.

Installation

  1. Add QuiltView to your Podfile: pod QuiltView
  2. Install the pod using pod install
  3. Add the layout as the subclass of your UICollectionView. To do that you set the Layout value to Custom and then select QuiltView as the Class and Module

    Subclass the layout

  4. Import QuiltView into your controller: import QuiltView
  5. Set the QuiltViewDelegate on the Controller hosting the UICollectionView. Next, depending on how you want the cells to appear you can set the width and height of them. You can set the width and heights to different values to create rectangular shapes or you can set the width and height to the same values to create squares.

    extension ViewController : QuiltViewDelegate {
      func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, blockSizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
    
        // get random width and height values for the cells
        let width  = self.numberWidths[indexPath.row]
        let height = self.numberHeights[indexPath.row]
    
        return CGSize(width: width, height: height)
      }
    
      // Set the spacing between the cells
      func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetsForItemAtIndexPath indexPath: IndexPath) -> UIEdgeInsets {
        return UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2)
      }
    }

Overrides

The following code shows how to override the default settings of QuiltView

let layout = self.collectionView?.collectionViewLayout as! QuiltView
// Set the layout to .horizontal if you want to scroll horizontally. 
// This setting is optional as the default is Vertical
layout.scrollDirection = UICollectionViewScrollDirection.vertical

// This sets the block or cell size. When the sizes are equal squares will be created.
// When the sizes are different, rectangular cells will be created. The default size 
// set by the library is 314 x 314. 
layout.itemBlockSize   = CGSize(
  width: 75,
  height: 75
)

NOTE: All delegate methods and properties are optional

Screen Shots

Screen shot

License

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

Changelog

Refer to the Releases page.

Latest podspec

{
    "name": "QuiltView",
    "version": "0.1.4",
    "summary": "QuiltView is a subclass of UICollectionViewLayout that positions various sized cells in a quilt like pattern.",
    "description": "QuiltView will layout CollectionView cells with various widths and heights on the page. The cells are positioned in a quilt style layout so each cell fits next to the other cell, leaving only the space defined by the UIEdgeInsets. You can provide widths and heights that are not equal creating rectangular shapes or you can specify a width and height that matches to ensure the cells are square. This library is a port of the RFQuiltLayout developed by Bryce Redd. That project can be found here: https://github.com/bryceredd/RFQuiltLayout",
    "homepage": "https://github.com/facetdigital/QuiltView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "jgroh9": "[email protected]"
    },
    "source": {
        "git": "https://github.com/facetdigital/QuiltView.git",
        "tag": "0.1.4"
    },
    "social_media_url": "https://twitter.com/FacetDigital",
    "platforms": {
        "ios": "10.2",
        "tvos": "10.1"
    },
    "source_files": "QuiltView/Classes/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This