Swiftpack.co - egzonpllana/InteractiveImageView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by egzonpllana.
egzonpllana/InteractiveImageView 1.0.21
Simple UIView to interact with an Image view like scroll, zoom, pinch and crop.
⭐️ 21
🕓 2 weeks ago
.package(url: "https://github.com/egzonpllana/InteractiveImageView.git", from: "1.0.21")


CocoaPods Carthage Swift Package Manager

Welcome to Interactive Image View, a simple library that provides an easier way to interact with image view, like scroll, zoom and crop. In its core it support two image content mode, the one is always square and the second one is custom. For example you can use aspect ration like instagram does 2:3 or 9:16, or any custom value. Basically, it's a thin wrapper around the UIScrollView and UIImageView APIs that UIKit provides.


  • Use at any place as UIView, no need to present or configure a viewcontroller.
  • Crop image at current position as user wants.
  • Scroll image view on x and y axis.
  • Double tap to zoom in or zoom out.
  • Pinch image view.


  1. Add a view, and set the class of the view view to InteractiveImageView.
  2. In your view controller, import InteractiveImageView.
  3. Connect view outlet, configure it with interactiveImageView.configure(...)
  4. Add delegates interactiveImageView.delegate = self
  5. Listen to delegate observers: extension ViewController: InteractiveImageViewDelegate { ... }


Configure view

if let image = UIImage(named: "image.png") {
    interactiveImageView.configure(withNextContentMode: .heightFill,
                      withFocusOffset: .center,
                      withImage: image,
                      withIdentifier: 0)

Crop and get image without delegate methods

let croppedImage = interactiveImageView.cropAndGetImage()

Toggle image content mode


User gestures

Double tap to zoom gesture

interactiveImageView.isDoubleTapToZoomAllowed = false

Scroll view

interactiveImageView.isScrollEnabled = false

Pinch to zoom gesture

interactiveImageView.isPinchAllowed = false

Example Project

You can download and run example project InteractiveImageViewExample. Its very useful to see how contraints of the view are set to make it work properly.





CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate InteractiveImageView into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'InteractiveImageView'


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate InteractiveImageView into your Xcode project using Carthage, specify it in your Cartfile:

github "egzonpllana/InteractiveImageView"

Swift Package Manager through Manifest File

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding InteractiveImageView as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/egzonpllana/InteractiveImageView.git", .upToNextMajor(from: "1.0.0"))

Swift Package Manager through XCode

To add InteractiveImageView as a dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter the repository URL



So, why was this made? While I was working on a project to provide an interactive image view based on given aspect ration, I could not find a suitable solution that offers all in one these features working in a single view without a need for a viewcontroller, so I build it.

Questions or feedback?

Feel free to open an issue, or find me @egzonpllana on LinkedIn.


Stars: 21
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Refactor crop image methods.
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics