Image view with support for zoom, scroll, and rotation. Support SwiftUI and UIKit.
@State var tapLocation: CGPoint = .zero
InteractiveImage(image: .init(named: "Iceland"), handleZoomingTap: $tapLocation)
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
}
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, animated: true)
}
Add the following dependency to your Package.swift file:
.package(url: "https://github.com/vospennikov/InteractiveImageView.git", .upToNextMinor(from: "1.0.4"))
Gestures is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 0 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics