Latest 0.3.0
Homepage https://github.com/prolificinteractive/Optik
License MIT
Platforms ios 9.0, requires ARC
Authors

Optik

Travis build status
Cocoapods Compatible
Platform
Docs

Description

Optik provides a simple viewing experience for a set of images, whether stored locally or remotely.

Optik

Requirements

  • iOS 9.0+
  • Xcode 8.1 or later

Installation

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

pod "Optik"

Usage

Optik can be used to display images stored either locally or remotely.

Displaying Images

Local Images

Local images can be displayed by creating an image viewer with an array of images:

let imageViewer = Optik.imageViewer(
    withImages: [
        UIImage(named: "image1.jpg")!,
        UIImage(named: "image2.jpg")!,
        UIImage(named: "image3.jpg")!
    ]
)

presentViewController(imageViewer, animated: true, completion: nil)

Remote Images

For remote images, an array of NSURLs should be provided – as well as an object conforming to the ImageDownloader protocol:

let imageDownloader = MyImageDownloader()

let imageViewer = Optik.imageViewer(
    withURLs: [
        NSURL(string: "https://somewebsite.com/image1.png")!,
        NSURL(string: "https://somewebsite.com/image2.png")!,
        NSURL(string: "https://somewebsite.com/image3.png")!
    ],
    imageDownloader: imageDownloader
)

presentViewController(imageViewer, animated: true, completion: nil)

Customizing the Image Viewer

Dismiss Button

The dismiss button image and position can be customized.

To indicate a custom dismiss button image, provide a dismissButtonImage parameter when creating an image viewer:

let imageViewer = Optik.imageViewer(
    withImages: [
        UIImage(named: "image1.jpg")!
    ],
    dismissButtonImage: UIImage(named: "MyDismissButton")
)

To indicate a position for the dismiss button, provide a dismissButtonPosition

let imageViewer = Optik.imageViewer(
    withImages: [
        UIImage(named: "image1.jpg")!
    ],
    dismissButtonImage: UIImage(named: "MyDismissButton"),
    dismissButtonPosition: .TopTrailing
)

Activity Indicator

When fetching remote images, an activity indicator is displayed while images are loaded. To indicate a custom activity indicator color, provide an activityIndicatorColor: parameter when creating an image viewer:

let imageViewer = Optik.imageViewer(
    withURLs: [
        NSURL(string: "https://somewebsite.com/image1.png")!
    ],
    imageDownloader: imageDownloader,
    activityIndicatorColor: UIColor.redColor()
)

Contributing to Optik

To report a bug or enhancement request, feel free to file an issue under the respective heading.

If you wish to contribute to the project, fork this repo and submit a pull request. Code contributions should follow the standards specified in the Prolific Swift Style Guide.

License

prolific

Copyright (c) 2017 Prolific Interactive

Marker is maintained and sponsored by Prolific Interactive. It may be redistributed under the terms specified in the LICENSE file.

Latest podspec

{
    "name": "Optik",
    "version": "0.3.0",
    "summary": "A Swift library for displaying images from any source, local or remote.",
    "description": "Optik provides a simple viewing experience for a set of images, whether stored locally or remotely.",
    "homepage": "https://github.com/prolificinteractive/Optik",
    "license": "MIT",
    "authors": {
        "htinlinn": "[email protected]"
    },
    "source": {
        "git": "https://github.com/prolificinteractive/Optik.git",
        "tag": "0.3.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "Optik/Classes/**/*",
    "resources": [
        "Optik/Assets/*.xcassets"
    ],
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This