Skip to content

Simple SwiftUI ImageView that enables dragging and zooming.

License

Notifications You must be signed in to change notification settings

rushairer/ZoomableImageView

Repository files navigation

ZoomableImageView

GitHub code size in bytes GitHub GitHub release (latest by date including pre-releases) GitHub tag (latest by date)

Simple SwiftUI ImageView that enables dragging and zooming.

Declaration

struct ZoomableImageView

Overview

Double Tap the view will zoom-in.

ZoomableImageView(image: UIImage(systemName: "photo")!)
@State var image: UIImage = UIImage()

var body: some View {
    ZoomableImageView(image: image, maximumZoomScale: 10)
        .task {
            do {
                let url = URL(string: "https://apod.nasa.gov/apod/image/2108/PlutoEnhancedHiRes_NewHorizons_960.jpg")!
                let (imageLocalURL, _) = try await URLSession.shared.download(from: url)
                let imageData = try Data(contentsOf: imageLocalURL)
                image = UIImage(data: imageData)!
            } catch {
                print(error)
            }
        }
}

History

History

LICENSE

The MIT License (MIT)

About

Simple SwiftUI ImageView that enables dragging and zooming.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages