appssemble / Zoomy

Adds seamless scrollView and instagram like zooming to UIImageViews in any view hierarchy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version Platform License

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

Example

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: Zoomable) {
        scrollView.isScrollEnabled = false
    }
    
    func didEndPresentingOverlay(for imageView: Zoomable) {
        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.

Texture

All the code examples provided above work with texture's ImageNode as well. All that is needed for this is adding extension ASImageNode: Zoomable {} anywhere in your targets sources. See the example projects for basic and more advanced usage of texture.

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.

Support

There may not always be time for personal support on how to implement Zoomy in different scenario's. Hopefully the code is clear enough to get done what's needed 💪. In case you've implemented a scenario thats not described in this readme or the examples, feel free to create a pull request, that would be pretty cool actually.

Installation

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

pod 'Zoomy'

Credits & Acknowledgements

Cover photo by Leonardo Yip, all other images that have been used can be found on Unsplash.

License

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

About

Adds seamless scrollView and instagram like zooming to UIImageViews in any view hierarchy.

License:MIT License


Languages

Language:Swift 97.9%Language:Ruby 2.1%