Latest 1.4.3
Homepage https://github.com/noblakit01/PhotoCollectionView
License MIT
Platforms ios 8.0, requires ARC
Dependencies SwiftyImageCache
Authors

Codacy Badge

Custom CollectionView like as Facebook Feed for iOS

Overview

Requirements

  • iOS 8.0+
  • Xcode 8+
  • Swift 3

Installation

CocoaPods

To integrate PhotoCollectionView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'PhotoCollectionView', '~> 1.4.3' 

Then, run the following command:

$ pod install

Manually

  • Drag and drop Sources folder into your project

Usage

Create PhotoCollectionView

Use can create instance of PhotoCollectionView by code:

import PhotoCollectionView
let photoCollectionView = PhotoCollectionView(frame: CGRect(x: 0, y: 0, width: 320, height: 240))

or create an UIView in storyboard and Outlet it

import PhotoCollectionView
@IBOutlet weak var imageCollectionView: PhotoCollectionView!

PhotoCollectionViewDataSource

  • Extension PhotoCollectionViewDataSource for binding data
extension ViewController: PhotoCollectionViewDataSource {
    func numPhotos(in photoCollectionView: PhotoCollectionView) -> Int {
        // Return count photo.
        return 10
    }

    // You can use image for data
    func photoColletionView(_ photoCollectionView: PhotoCollectionView, imageAt index: Int) -> UIImage? {
        // return image need to show.
        return UIImage(named: "image(index + 1)")
    }

    // or use image url
    func photoCollectionView(_ photoCollectionView: PhotoCollectionView, urlImageAt index: Int) -> URL? {
        return URL(string: *your image URL here*)
    }

}
  • Set dataSource of PhotoCollectionView
imageCollectionView.dataSource = self

PhotoCollectionViewDelegate

Handle image selection in PhotoCollectionView

imageCollectionView.delegate = self
extension ViewController: PhotoCollectionViewDelegate {
    func photoCollectionView(_ photoCollectionView: PhotoCollectionView, didSelectImageAt index: Int) {
        print("Press at index (index)")
    }
}

TODO

Author

Luan Tran – [email protected]

License

MIT

Latest podspec

{
    "name": "PhotoCollectionView",
    "version": "1.4.3",
    "summary": "Custom CollectionView like as Facebook Feed for iOS.",
    "description": "Simple and highly customizable iOS list image for feed, in Swift. Like Facebook feed.",
    "homepage": "https://github.com/noblakit01/PhotoCollectionView",
    "license": "MIT",
    "authors": {
        "noblakit": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/noblakit01/PhotoCollectionView.git",
        "tag": "1.4.3"
    },
    "source_files": "Sources/*.swift",
    "requires_arc": true,
    "dependencies": {
        "SwiftyImageCache": [
            "~> 1.2.0"
        ]
    },
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This