ryohey / Zoomable

A SwiftUI view modifier that provides pinch to zoom, double tap to zoom, and drag to pan functionalities.
MIT License
69 stars 7 forks source link

Zoomable

A SwiftUI view modifier that provides pinch to zoom, double tap to zoom, and drag to pan functionalities for iOS ad iPadOS apps.

Supports Image and any kind of View, including UIViewControllerRepresentable and UIViewRepresentable.

https://github.com/ryohey/Zoomable/assets/5355966/d88a9290-ee1d-4dd9-ac2c-b1e68548d256

Features

Installation

Swift Package Manager

Please add the following URL in the Package Dependencies screen in Xcode.

https://github.com/ryohey/Zoomable.git

Usage

To use the Zoomable modifier in your SwiftUI view:

import Zoomable

struct ContentView: View {
    var body: some View {
        Image("your-image-name")
            .zoomable()

        /*
        or
        SomeView()
            .zoomable(
                minZoomScale: 0.5,        // Default value: 1
                doubleTapZoomScale: 2,    // Default value: 3
                outOfBoundsColor: .black  // Default value: .clear
            )
        */
    }
}

Requirements

Caveats

Contribution

Contributions are welcome! Please open an issue or submit a pull request.

License

MIT License