Latest 2.0.0
Homepage https://github.com/mennolovink/Zoomy
License MIT
Platforms ios 8.0
Dependencies PureLayout, InjectableLoggers
Authors

Zoomy

Version Platform License

Zoomy allows you to add seamless scrollView and instagram like zooming to UIImageViews in any view hierarchy.

Example

ZoomyZoomyZoomy

To run the example project, clone the repo, and run pod install from the Example directory first.

Setup

Just add

import Zoomy

to the files that of the code that needs zoombehavior.

Usage

All of the folowing snippets are expected to be called from within to your viewcontroller.

Somewhere after viewDidLoad should work just fine.

Scrollable zooming

addZoombehavior(for: imageView)

Insta zooming

addZoombehavior(for: imageView, settings: .instaZoomSettings)

Zooming above navigationbar/tabbar

guard let parentView = parent?.view else { return }
addZoombehavior(for: imageView, in:parentView)

Zooming below UI element

addZoombehavior(for: imageView, below: dismissButton)

Zooming with some custom gesture actions

let settings = Settings.defaultSettings
    .with(actionOnTapOverlay: Action.dismissOverlay)
    .with(actionOnDoubleTapImageView: Action.zoomIn)

addZoombehavior(for: imageView, settings: settings)

There’s a lot more triggers and actions to choose from.

Zooming a collectionviewcell

public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    //After your regular dequeue and configuration:
    addZoombehavior(for: cell.imageView)

    return cell
}

Other examples

pod try 'Zoomy' to load the example project.

Or check some of the sample code directly:

A note about zooming images that live inside scrollviews

Zooming inside any viewhierarchy will work perfectly fine using Zoomy, however sometimes you want to disable existing behaviors while zooming. A good example of this is when zooming images that are subviews of a scrollview.

For best performance just implement these Zoomy.Delegate methods:

extension YourViewController: Zoomy.Delegate {

    func didBeginPresentingOverlay(for imageView: UIImageView) {
        scrollView.isScrollEnabled = false
    }

    func didEndPresentingOverlay(for imageView: UIImageView) {
        scrollView.isScrollEnabled = true
    }
}

No need to set the viewController as a delegate to anyting. This is infered using conditional conformance. In case you’re interested in seeing how this is done, see this and this.

There’s more to come

See the roadmap for upcoming features.

Missing anyting or something is not working as desired? Create an issue and it will likely be picked up.

Installation

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

pod 'Zoomy'

Author

Menno Lovink, [email protected]

License

Zoomy is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Zoomy",
    "version": "2.0.0",
    "summary": "Zoomy allows UIScrollView like zooming on UIImageViews in any view hierarchy",
    "description": "Zoomy allows UIScrollView like zooming on UIImageViews in any view hierarchy with close to no alterations to clients layout. Zoomy works by initialy performing translate and scale manipulations on a view mimicking the original view that is to bee zoomed from, triggered by a pinch and (while the pinch has started) a pan gesture. As soon as the initial gesture is done a scrollView is placed and configured in the optimal postion in relation to the last location of the manipulated view. From this point on all manipulations are happening inside a scrollview and behave like you'd expect it to do.",
    "homepage": "https://github.com/mennolovink/Zoomy",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Menno Lovink": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mennolovink/Zoomy.git",
        "tag": "2.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Zoomy/Classes/**/*",
    "dependencies": {
        "PureLayout": [
            "~> 3.0"
        ],
        "InjectableLoggers": [
            "~> 1.0"
        ]
    }
}

Pin It on Pinterest

Share This