All Projects → sgr-ksmt → BeautifulGridLayout

sgr-ksmt / BeautifulGridLayout

Licence: MIT License
UICollectionView extension for showing beautiful grid!

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

BeautifulGridLayout

Carthage Compatible

UICollectionView extension for showing beautiful grid!

Sample

sample

If you execute sample, clone or download this repository and open demo project.

Usage

  • call adaptBeautifulGrid:gridLineSpace(:sectionInset) when you want to update.
collectionView.adaptBeautifulGrid(4, gridLineSpace: 2.0)

// If you want to set sectionInset
let inset = UIEdgeInsetsMake(0.0, 4.0, 0.0, 4.0)
collectionView.adaptBeautifulGrid(4, gridLineSpace: 2.0, sectionInset: inset)

With Autolayout

If collectionView's frame changed by Autolayout, call adaptBeautifulGrid:gridLineSpace(:sectionInset) in viewDidLayoutSubviews.

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    view.layoutIfNeeded() // need to call before update collection view layout.

    collectionView.adaptBeautifulGrid(4, gridLineSpace: 2.0)
}

With Rotation

If Device'rotation changed, call adaptBeautifulGrid:gridLineSpace(:sectionInset) in viewDidLayoutSubviews.

e.g. : Portrait→4, Landscape→6

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    view.layoutIfNeeded() // need to call before update collection view layout.

    let isLandscape = UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation)
    let perRow = 4 + (isLandscape ? 2 : 0)
    collectionView.adaptBeautifulGrid(perRow, gridLineSpace: 2.0)
}

Requirements

  • iOS 8.0+
  • Xcode 7.0+(Swift 2+)

Installation and Setup

Carthage

  • Add the following to your Cartfile:
github "sgr-ksmt/BeautifulGridLayout"
  • Run carthage update
  • Add the framework as described.
    Details: Carthage Readme

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request. :)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].