Git Product home page Git Product logo

agrume's Introduction

Carthage compatible

Agrume

An iOS image viewer written in Swift with support for multiple images.

Requirements

  • iOS 8.0+
  • Xcode 6.3+

Installation

The easiest way is through CocoaPods. Simply add the dependency to your Podfile and then pod install:

pod 'Agrume', '~> 1'

Or Carthage. Add the depdency to your Cartfile and then carthage update:

github "JanGorman/Agrume" >= 1

How

There are multiple ways you can use the image viewer (and the included Example project shows them all).

For just a single image it's as easy as

import Agrume

@IBAction func openImage(sender: AnyObject) {
	if let image = UIImage(named: "") {
		let agrume = Agrume(image: image)
		agrume.showFrom(self)	
	}
}

You can also pass in an NSURL and Agrume will take care of the download for you.

If you're displaying a UICollectionView and want to add support for zooming, you can also call Agrume with an array of either images or URLs.

let agrume = Agrume(images: images, startIndex: indexPath.row, backgroundBlurStyle: .Light)
agrume.didScroll = {
	[unowned self] index in
    self.collectionView?.scrollToItemAtIndexPath(NSIndexPath(forRow: index, inSection: 0),
    	atScrollPosition: .allZeros,
        animated: false)
}
agrume.showFrom(self)

This shows a way of keeping the zoomed library and the one in the background synced.

If you want to take control of downloading images (e.g. for caching), you can also set a download closure that calls back to Agrume to set the image. I can recommend MapleBacon.

import Agrume
import MapleBacon

@IBAction func openURL(sender: AnyObject) {
	let agrume = Agrume(imageURL: NSURL(string: "https://dl.dropboxusercontent.com/u/512759/MapleBacon.png")!, backgroundBlurStyle: .Light)
	agrume.download = {
		url, completion in
		let manager = ImageManager.sharedManager
		manager.downloadImageAtURL(url) {
			imageInstance, error in
			if error == nil {
				completion(image: imageInstance.image)
			} else {
				completion(image: nil)
			}
		}
	}
	agrume.showFrom(self)
}

Acknowledgements

Agrume was inspired by the phenomal work done by Jared Sinclair on JTSImageViewController. This project wouldn't have seen the light of day as quickly without it.

Licence

Agrume is released under the MIT license. See LICENSE for details

agrume's People

Contributors

jangorman avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

iostestapps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.