InteractiveImageView

1.1.0

Image and ImageView with zoom, scroll and rotation
vospennikov/InteractiveImageView

What's New

1.1.0

2023-12-03T06:29:53Z

Full Changelog: 1.0.8...1.1.0

InteractiveImageView

Swift Platform Framework Swift Package Manager GitHub

InteractiveImageView is an open-source library that provides experience showing images like a Photos App on iPhone. (Tap to zoom, pinch and pan gestures, rotation with keep position, motion inertia). The view supports UIKit and SwiftUI framework.

Demo

Usage

SwiftUI

@State var tapLocation: CGPoint = .zero
InteractiveImage(image: .init(named: "Iceland"), zoomInteraction: .init(location: tapLocation, scale: 1.2, animated: true)

SwiftUI before iOS 16 didn't support touch location detection. To zoom to the touch location, you could use the Gestures package.

.onTouchGesture(count: 2) { gesture in
  tapLocation = gesture.location
}

UIKit

var interactiveImageView = InteractiveImageView(maxScale: 2.0)
interactiveImageView.image = UIImage(named: "Iceland")

func gestureHandler(_ sender: UITapGestureRecognizer) {
  let location = sender.location(in: imageView)
  interactiveImageView.zoom(to: location, scale: 2.0, animated: true)
}

Installation

Swift Package Manager

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/vospennikov/InteractiveImageView.git", .upToNextMinor(from: "1.1.0"))

License

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

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Oct 17 2024 18:40:07 GMT-0900 (Hawaii-Aleutian Daylight Time)