Swiftpack.co - Package - lvnkmn/Zoomy

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 Swift Package Manager. To install it, simply add it to your project using this repository's URL as explained here.

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.

Github

link
Stars: 122

Dependencies

Used By

Total: 0

Releases

4.0.0 -

Closed Issues

Breaking changes

  • Zoomy.delegate methods now use Zoomable instead of UIImage
  • All previously deprecated types, methods and variables have been removed

3.1.0 -

3.0.0 -

2.0.1 -

2.0.0 -

1.12.1 -

1.11.1 -

1.11.0 -

1.10.2 -

1.10.1 -

1.10.0 -

1.9.4 -

1.9.3 -

1.9.2 -

1.9.1 -

1.9.0 -

1.8.2 -

1.8.1 -

1.8.0 -

1.7.2 -

1.7.1 -

1.7.0 -

1.6.3 -