Skip to content

A drag and drop, reorderable, image grid suitable for a profile picture selector written in Swift for iOS.

License

Notifications You must be signed in to change notification settings

miraan/ImageGridView

Repository files navigation

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, [email protected]

License

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

About

A drag and drop, reorderable, image grid suitable for a profile picture selector written in Swift for iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages