Skip to content

A fullscreen image viewer with pinch-zooming built using SwiftUI.

Notifications You must be signed in to change notification settings

shimajiron/swiftui-image-viewer

 
 

Repository files navigation

🌅 SwiftUIImageViewer

A fullscreen image viewer with pinch-zooming built using SwiftUI.

image

👩‍🔧 Installation

File -> Swift Packages -> Add Package Dependancy..

https://github.com/fuzzzlove/swiftui-image-viewer.git

👩‍💻 Usage

import SwiftUI
import SwiftUIImageViewer

struct ContentView: View {

    @State private var isImagePresented = false

    var body: some View {
        image
            .resizable()
            .scaledToFit()
            .cornerRadius(12)
            .frame(width: 260, height: 260)
            .onTapGesture {
                isImagePresented = true
            }
            .fullScreenCover(isPresented: $isImagePresented) {
                SwiftUIImageViewer(image: image)
                    .overlay(alignment: .topTrailing) {
                        closeButton
                    }
            }
    }

    private var image: Image {
        Image("dogs")
    }

    private var closeButton: some View {
        Button {
            isImagePresented = false
        } label: {
            Image(systemName: "xmark")
                .font(.headline)
        }
        .buttonStyle(.bordered)
        .clipShape(Circle())
        .tint(.purple)
        .padding()
    }
}

About

A fullscreen image viewer with pinch-zooming built using SwiftUI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%