Zoomy allows you to add seamless scrollView and instagram like zooming to UIImageViews in any view hierarchy.
Example project can be found in the Example folder
Just add
import Zoomy
to the files that of the code that needs zoombehavior.
All of the folowing snippets are expected to be called from within to your viewcontroller.
Somewhere after viewDidLoad
should work just fine.
addZoombehavior(for: imageView)
addZoombehavior(for: imageView, settings: .instaZoomSettings)
guard let parentView = parent?.view else { return }
addZoombehavior(for: imageView, in:parentView)
addZoombehavior(for: imageView, below: dismissButton)
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.
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//After your regular dequeue and configuration:
addZoombehavior(for: cell.imageView)
return cell
}
- Zooming non centered images
- Zooming scrollable images
- Zooming underneath floating action button
- Dynamically changing gesture actions
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.
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.
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.
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.
Zoomy is available through Swift Package Manager. To install it, simply add it to your project using this repository's URL as explained here.
Cover photo by Leonardo Yip, all other images that have been used can be found on Unsplash.
Zoomy is available under the MIT license. See the LICENSE file for more info.