CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

NHPhotosViewer 0.1.2

NHPhotosViewer 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Ngo Hung.



  • By
  • Ngo Hung

Simple photos viewer written in Swift.

NHPhotosViewer is designed to be presented within a navigation controller. Simply set the delegate (which must conform to NHPhotosViewControllerDelegate) and implement the 2 required delegate methods to provide the photo viewer with the data in the form of NHPhoto objects. You can create an NHPhoto object by providing a UIImage object, or a URL containing the path to a file or an image online.

Downloading/caching of images are done via Kingfisher library.

Status

Project under development. Missing many features. Just a very simple image gallery for now.

Code Example

import NHPhotosViewer
...

override func viewDidLoad() {
    let urls : [String] =
    [   
        "http://somedomain.com/image.png",
        "http://somedomain.com/anotherimage.png",
        ...
    ]

    ...

    for url in urls {
        let photo = NHPhoto(url: URL(string: url)! )
        // set placeholder image if necessary
        //photo.placeholder_image = placeholderImg
        photos.append(photo)
    }

    self.viewer = NHPhotosViewController()
    self.viewer?.delegate = self
    self.viewer?.numOfColumns = 4

}

// open viewer with navigation controller
@IBAction func openViewer(_ sender: AnyObject) {

    self.viewer?.navigationItem.title = "Photos"
    self.navigationController?.pushViewController(self.viewer!, animated: false)

}

//NHPhotosViewControllerDelegate
func numOfPhotos(photoController: UIViewController ) -> Int{
    return photos.count
}

func photo(photoController: UIViewController, index: Int) -> NHPhoto {
    return photos[index]
}