vospennikov/interactiveimageview
## InteractiveImageView
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.
Package Metadata
Repository: vospennikov/interactiveimageview
Default branch: main
README: README.md