Latest 0.1.2
Homepage https://github.com/thehung111/NHPhotosViewer
License MIT
Platforms ios 8.0, requires ARC
Dependencies Kingfisher
Frameworks CFNetwork
Authors

Simple photos viewer written in Swift.

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.

Installation via CocoaPods

pod "NHPhotosViewer"

Documentation

https://thehung111.github.io/NHPhotosViewer/

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]
}

Latest podspec

{
    "name": "NHPhotosViewer",
    "version": "0.1.2",
    "summary": "Simple photo viewer written in Swift.",
    "description": "Simple photos viewer written in Swift",
    "homepage": "https://github.com/thehung111/NHPhotosViewer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Ngo Hung": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/thehung111/NHPhotosViewer.git",
        "tag": "0.1.2"
    },
    "source_files": "NHPhotosViewer/NHPhotosViewer/**/*.{h,swift}",
    "frameworks": "CFNetwork",
    "requires_arc": true,
    "dependencies": {
        "Kingfisher": [
            "~> 3.1"
        ]
    },
    "xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This