Simple UIView to interact with an Image view like scroll, zoom, pinch and crop.

Overview

“InteractiveImageView”

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.

Features

  • 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.

How to use

  1. Add a view, and set the class of the view view to InteractiveImageView.
  2. Dimensions of the view must be equal in width and equal height, for example, 400x400.
  3. Use AspectRatio for height, set width manually. See Example Project.
  4. In your view controller, import InteractiveImageView.
  5. Connected view outlet, configure it with interactiveImageView.configure(...)
  6. Add delegates interactiveImageView.delegate = self
  7. Listen to delegate observers: extension ViewController: InteractiveImageViewDelegate { ... }

Control user actions

  • Double tap to zoom: interactiveImageView.isDoubleTapToZoomAllowed
  • Scroll view: interactiveImageView.isScrollEnabled
  • Pinch gesture: interactiveImageView.isPinchAllowed

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.

Preview

“InteractiveImageView”

Installation

CocoaPods

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

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

https://github.com/egzonpllana/InteractiveImageView.git

Backstory

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.

You might also like...
WhiteAndFluffyTest - Scroll images and add them to your favourites via image page
WhiteAndFluffyTest - Scroll images and add them to your favourites via image page

Image service application Scroll images and add them to your favourites via imag

An image download extension of the image view written in Swift for iOS, tvOS and macOS.
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.
AYImageKit is a Swift Library for Async Image Downloading, Show Name's Initials and Can View image in Separate Screen.

AYImageKit AYImageKit is a Swift Library for Async Image Downloading. Features Async Image Downloading. Can Show Text Initials. Can have Custom Styles

DOMKit - Swift framework to interact with the DOM in the browser

DOMKit Swift framework to interact with the DOM in the browser. Note: This proje

Twitter Image Pipeline is a robust and performant image loading and caching framework for iOS clients

Twitter Image Pipeline (a.k.a. TIP) Background The Twitter Image Pipeline is a streamlined framework for fetching and storing images in an application

📷 A composable image editor using Core Image and Metal.
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component 🎉 v2.0.0-alpha now open!

📷 A composable image editor using Core Image and Metal.
📷 A composable image editor using Core Image and Metal.

Brightroom - Composable image editor - building your own UI Classic Image Editor PhotosCrop Face detection Masking component 🎉 v2.0.0-alpha now open!

A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image.

QRDecode A complete Mac App: drag an image file to the top section and the bottom section will show you the text of any QRCodes in the image. QRDecode

Releases(1.0.21)
Owner
Egzon Pllana
Passionate iOS Developer
Egzon Pllana
A snappy image viewer with zoom and interactive dismissal transition.

A snappy image viewer with zoom and interactive dismissal transition. Features Double tap to zoom in/out Interactive dismissal transition Animate in f

Lucas 420 Aug 12, 2022
Zoomable - A container that allows you to zoom in and out of an image using only SwiftUI

Zoomable It is a container that allows you to zoom in and out of an image using

jasu 39 Aug 25, 2022
Simple image crop library for iOS

PhotoCropper This is a simple image crop library for iOS I made for fun on Chris

Aaron Lee 5 Jun 21, 2022
✂️ Detect and crop faces, barcodes and texts in image with iOS 11 Vision api.

ImageDetect ImageDetect is a library developed on Swift. With ImageDetect you can easily detect and crop faces, texts or barcodes in your image with i

Arthur Sahakyan 296 Aug 29, 2022
Image picker with custom crop rect for iOS written in Swift (Ported over from GKImagePicker)

WDImagePicker Ever wanted a custom crop area for the UIImagePickerController? Now you can have it with WDImagePicker. Just set your custom crop area a

Wu Di 95 Jul 27, 2022
Crop faces, inside of your image, with iOS 11 Vision api.

FaceCropper Requirements Xcode 9.0 (beta) or higher. iOS 11.0 (beta) or higher. (It is possible to import this library under the iOS 11. But it won't

Taejun Kim 488 Aug 31, 2022
A view controller for iOS that allows users to crop portions of UIImage objects

TOCropViewController TOCropViewController is an open-source UIViewController subclass to crop out sections of UIImage objects, as well as perform basi

Tim Oliver 4.4k Sep 24, 2022
TextDrawer, is a UIView allows you to add text, with gesture, on UIView, or UIImage

TextDrawer TextDrawer, is a UIView allows you to add text, with gesture, on UIView, or UIImage. About Annotating Images TextDrawer is the easiest way

Remi ROBERT 105 Jul 20, 2022
A crop, compression, resize and trimming library for videos, based on AVKit.

VideoKit VideoKit is a high level layer on top of AVKit How it works // With this config, the video will get resized to 1920x1080p, the maximal length

Knoggl 5 Sep 23, 2022
Autocrop - A face-aware crop utility using OSX's Vision framework

autocrop A high-performance face-aware crop utility using OSX's Vision framework

Alex Dong 0 Jan 19, 2022