https://github.com/prolificinteractive/optik
A Swift library for displaying images from any source, local or remote.
https://github.com/prolificinteractive/optik
Last synced: about 1 year ago
JSON representation
A Swift library for displaying images from any source, local or remote.
- Host: GitHub
- URL: https://github.com/prolificinteractive/optik
- Owner: prolificinteractive
- License: mit
- Created: 2016-05-14T13:34:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-10-16T23:04:18.000Z (over 6 years ago)
- Last Synced: 2025-04-19T07:11:21.404Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 12.3 MB
- Stars: 25
- Watchers: 24
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://travis-ci.org/prolificinteractive/Optik)
[](https://img.shields.io/cocoapods/v/Optik.svg)
[](http://cocoadocs.org/docsets/Optik)
[](http://cocoadocs.org/docsets/Optik)
## Description
Optik provides a simple viewing experience for a set of images, whether stored locally or remotely.

## Requirements
* iOS 9.0+
* Xcode 8.1 or later
## Installation
Optik is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your `Podfile`:
```ruby
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:
```swift
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:
```swift
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:
```swift
let imageViewer = Optik.imageViewer(
withImages: [
UIImage(named: "image1.jpg")!
],
dismissButtonImage: UIImage(named: "MyDismissButton")
)
```
To indicate a position for the dismiss button, provide a `dismissButtonPosition`
```swift
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:
```swift
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](https://github.com/prolificinteractive/swift-style-guide).
## License

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.
[LICENSE]: ./LICENSE