Code Monkey home page Code Monkey logo

irregularcollectionuikit's Introduction

IrregularCollectionUIKit

Swift Objective-C CI Status Version License Platform Carthage Compatible

Example

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

You can implement layout of collection view like this screenshot :)

Implementation for collection view with the class IrregularCollectionViewController using UIKit

class DemoViewController: IrregularCollectionViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        collectionViewLayout.columnSpacing = 1
        collectionViewLayout.numberOfColumns = 3
        collectionViewLayout.sectionInset = UIEdgeInsetsMake(1, 1, 1, 1)
        collectionView.register(SampleViewCell.self, forCellWithReuseIdentifier: "SampleViewCell")
    }
    override func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 1
    }
    override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return contents.count
    }
    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        return collectionView.dequeueReusableCell(withReuseIdentifier: "SampleViewCell", for: indexPath)
    }
    override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
        (cell as? SampleViewCell)?.content = contents[indexPath.item]
    }
    override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, originalItemSizeAt indexPath: IndexPath) -> CGSize {
        let content = contents[indexPath.item]
        return CGSize(width: CGFloat(content.width), height: CGFloat(content.height))
    }
}

Implementation for collection view with IrregularCollectionViewLayout

let layout = IrregularCollectionViewLayout()
layout.delegate = self
layout.columnSpacing = 1
layout.numberOfColumns = 3
layout.sectionInset = UIEdgeInsetsMake(1, 1, 1, 1)
        
let collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)

Requirements

iOS Deployment Target 7.0 higher

Installation

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

pod "IrregularCollectionUIKit"

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "pisces/IrregularCollectionUIKit" ~> 2.0.1

Run carthage update to build the framework and drag the built IrregularCollectionUIKit.framework into your Xcode project.

Author

Steve Kim, [email protected]

License

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

irregularcollectionuikit's People

Contributors

pisces avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.