Skip to content
A drag and drop, reorderable, image grid suitable for a profile picture selector written in Swift for iOS.
Swift
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
ImageGridView
.gitattributes
.gitignore
.travis.yml
ImageGridView.podspec
LICENSE
README.md
_Pods.xcodeproj

README.md

ImageGridView

A drag and drop, reorderable, image grid suitable for a profile picture selector.

This Cocoa Pod gives you an image grid view which displays images. Images can be dragged and dropped to be reordered. There are buttons to delete images and add new images. The grid automatically resizes when more images are added. You can hook in delegate methods to control the behaviour when the user taps delete or add. This was originally designed for a profile picture selector on an edit profile screen.

CI Status Version License Platform

Example

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

alt text

Usage

It's as simple as:

let imageGridView = ImageGridView(frame: imageGridViewContainer.bounds)
imageGridView.delegate = self
imageGridView.datasource = self
imageGridViewContainer.addSubview(imageGridView)
imageGridView.reload()

Just implement the datasource method:

func imageGridViewImages(_ imageGridView: ImageGridView) -> [UIImage]

And the delegate methods:

func imageGridView(_ imageGridView: ImageGridView, didTapDeleteForImage index: Int)
func imageGridViewDidTapAddImage(_ imageGridView: ImageGridView)
func imageGridView(_ imageGridView: ImageGridView, didMoveImage fromIndex: Int, toIndex: Int)

You can also set additional options to override the defaults:

imageGridView.maxCapacity = 7

For a full working example, see ViewController.swift in the Example project.

Installation

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

pod 'ImageGridView'

Author

miraan, miraan@triprapp.com

License

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

You can’t perform that action at this time.