Latest 0.1.0
Homepage https://github.com/luccafgf/Mozaic
License MIT
Platforms ios 8.0
Authors

Mozaic

Mozaic is a library for building custom CollectionViews. It provides a simple interface for assembling a mosaic layout based in encapsulated columns and three cell types.

CI Status
Version
License
Platform

Installation

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

pod 'Mozaic'

Implementation and Usage

Import Mozaic to the Controller where it will be used.

import Mozaic

Now, create a constant with a Mozaic layout, attribute it’s to your collectionView layout and assign its delegate to the actual class.

override func viewDidLoad() {
super.viewDidLoad()
...
let mozaicLayout = Mozaic()
self.yourCollectionView.collectionViewLayout = mozaicLayout
mozaicLayout.delegate = self
...
}

At this point, you will see that Xcode will show an error saying that mozaicLayout.delegate = self cannot be assigned. It’s because you have not yet extended your class with MozaicDelegate.

To fix this, do:

class YourViewController: MozaicDelegate {

...

}

Now, you will see that an error will appear, saying that your class doesn’t conform with MozaicDelegate, and Xcode will ask you if do you want to add protocol stubs. After clicking the add button, the method setStyleOfEachColumn will appear.

This method returns an array with arrays of CellType, so if you pass an array like this:


func setStyleOfEachColumn() -> [[MozaicCellType]] {
return [[.Medium, .Small, .Medium], [.Large, .Small, .Small]]
}

You’ll has a collection like in this image below

sizes

Explaining: each array will generate a column in the collectionView, being that each column will follow its cellsStyle pattern. So the first column, in this case, will draw the sequence [.Medium, .Small, .Medium] repeatedly while it necessary.

The MozaicLayout will generate a column for each array you pass, so you don’t have any limitations here about the minimum or the maximum number of columns. Be careful about that, please!

The sizes of the cells are based on the column width and on the number of columns.
LargeCellWidth = collectionViewContentWidth / numberOfColumns

Optional Methods

Mozaic offers these optional methods too.


func setCellHeightProportion() -> CGFloat                 //Default return = 1.0

func setHorizontalSpaceBetweenCells() -> CGFloat          //Default return = 15.0

func setVerticalSpaceBetweenCells() -> CGFloat            //Default return = 15.0

spaces

Author

Lucca França Gomes Ferreira – luccafgf – [email protected]

License

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

Latest podspec

{
    "name": "Mozaic",
    "version": "0.1.0",
    "summary": "A library for building custom CollectionViews.",
    "description": "'Mozaic is a library for building custom CollectionViews. It provides a simple interface for assembling a mosaic layout based in encapsulated columns and three cell types.'",
    "homepage": "https://github.com/luccafgf/Mozaic",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "luccafgf": "[email protected]"
    },
    "source": {
        "git": "https://github.com/luccafgf/Mozaic.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Mozaic/Classes/**/*",
    "swift_version": "4.1"
}

Pin It on Pinterest

Share This