Latest 0.2.0
Homepage https://github.com/farisalbalawi/PinterestUISwift
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

Language: Swift 5
CI Status
Version
License: MIT
Platform

SkinnyExemplaryAcornweevil-small

Features

  • Supports Headers and Footers
  • Highly Customizable
  • Change the number of columns
  • swift 5

Example

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

Requirements

Installation

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

pod 'PinterestUISwift'

Usage

import PinterestUISwift

class ViewController: UIViewController, collectionViewFlowDataSource{

// MARK: Variables
var collectionView: UICollectionView!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

let layout = collectionViewLayout(delegate: self)
if #available(iOS 10.0, *) {
layout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
} else {
// Fallback on earlier versions
}
collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height:self.view.frame.height), collectionViewLayout: layout)

collectionView.backgroundColor = .white
collectionView.dataSource = self
collectionView.delegate = self
collectionView.showsHorizontalScrollIndicator = false
collectionView.showsVerticalScrollIndicator = false
view.addSubview(collectionView)

collectionView.register(UINib(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "CollectionViewCell")

let nib:UINib = UINib(nibName: "Header", bundle: nil)
collectionView.register(nib, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "Header")

}
}

Functions

Height of the items at index path:

func sizeOfItemAtIndexPath(at indexPath: IndexPath) -> CGFloat {
// take image height and return the height
let height = Float.random(in: 80 ..< 400)
return CGFloat(height)
}

number of columns:

func numberOfCols(at section: Int) -> Int {
return 2

}

space of columns:

func spaceOfCells(at section: Int) -> CGFloat{
return 12
}

UICollectionview Section Inset:

func sectionInsets(at section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 10, left: 10, bottom: 50, right: 10)
}

size Of Header:

func sizeOfHeader(at section: Int) -> CGSize{
return CGSize(width: view.frame.width, height: 150)
}

height Of Additional Content:

func heightOfAdditionalContent(at indexPath : IndexPath) -> CGFloat{
return 0
}

Author

Faris Albalawi, [email protected]

License

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

Latest podspec

{
    "name": "PinterestUISwift",
    "version": "0.2.0",
    "swift_version": "5",
    "summary": "UICollectionView Custom Layout",
    "description": "'Open source project in order to implement Pinterest like Custom collection view layout with different image and text sizes.'.",
    "homepage": "https://github.com/farisalbalawi/PinterestUISwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Faris Albalawi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/FarisAlbalawi/PinterestUISwift.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "PinterestUISwift/Classes/*.swift",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This