An image viewer built using SwiftUI

An image viewer built using SwiftUI

An image viewer built using SwiftUI. Featuring drag to dismiss, pinch to zoom, remote and local images, and more.

An image viewer built using SwiftUI. Featuring drag to dismiss, pinch to zoom, remote and local images, and more.

SwiftUI-Image-Viewer

Installation via Swift Package Manager

File > Swift Packages > Add Package Dependancy

https://github.com/Jake-Short/swiftui-image-viewer.git

Usage

Local Image:

The image parameter accepts Binding<Image> in all versions. As of 1.0.20, it also accepts Binding<Image?>

import ImageViewer

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var image = Image("example-image")

    var body: some View {
        VStack {
            Text("Example!")
        }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer))
    }
}

Remote Image:

The imageURL parameter accepts Binding<String>

import ImageViewerRemote

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var imgURL: String = "https://..."

    var body: some View {
        VStack {
            Text("Example!")
        }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewerRemote(imageURL: self.$imgURL, viewerShown: self.$showImageViewer))
    }
}

Customization

HTTP Headers

Availability: 1.0.15 or higher

The remote image viewer allows HTTP headers to be included in the URL request. To use them, pass a dictonary to the httpHeaders field. The format should be [Header: Value], both strings.

Example:

import ImageViewerRemote

struct ContentView: View {
    @State var showImageViewer: Bool = true

    var body: some View {
        VStack {
            Text("Example!")
        }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewerRemote(imageURL: URL(string: "https://..."), viewerShown: self.$showImageViewer, httpHeaders: ["X-Powered-By": "Swift!"]))
    }
}

Explicit Aspect Ratio

Availability: 1.0.21 or higher

An explcit image aspect ratio can be specified, which fixes an issue of incorrect stretching that occurs in certain situations. The aspectRatio parameter accepts Binding<CGFloat>

Example:

import ImageViewer

struct ContentView: View {
    @State var showImageViewer: Bool = true
    @State var image = Image("example-image")

    var body: some View {
        VStack {
            Text("Example!")
        }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewer(image: self.$image, viewerShown: self.$showImageViewer, aspectRatio: .constant(2)))
    }
}

Disable Cache

Availability: 1.0.25 or higher

To disable cache on the remote image viewer, simply pass a Bool value to the disableCache parameter

Example:

import ImageViewerRemote

struct ContentView: View {
    @State var showImageViewer: Bool = true

    var body: some View {
        VStack {
            Text("Example!")
        }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
        .overlay(ImageViewerRemote(imageURL: URL(string: "https://..."), viewerShown: self.$showImageViewer, disableCache: true))
    }
}

Compatibility

This package is compatible on iOS 13 and later.

Previous to 1.0.18, this package used Swift tools version 5.2. If you receive an error while trying to use the package, you may be on an older version of Xcode, and should use version 1.0.18 of this package or later.

As of 1.0.18 and later, this package uses Swift tools version 5.1, allowing for compatibility with more Xcode versions.

GitHub

https://github.com/Jake-Short/swiftui-image-viewer

swiftui ios swift mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How To Succeed In Mobile App Wireframe Design?

This article covers everything about mobile app wireframe design: what to do and what not, tools used in designing a mobile or web app wireframe, and more.

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Best Mobile App Development Company | Android and iOS Apps

iPrism Tech is a one of the best and offshore mobile app development company in India, Saudi Arabia and USA. We are a major providers of android, iphone and ipad mobile app development services at economical prices.

Top iOS Mobile App Development Agency in New York

Are you looking for a [Top iOS Mobile App Development Agency in New York]**(https://www.appcluesinfotech.com/ios-app-develop**ment-company/ "Top iOS Mobile App Development Agency in New York") for your app projects? Then AppClues Infotech is the...

Hire iOS App Developer

Are you looking to transform your idea into an iPhone application? Hire iPhone programmer team from **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")** to ensure the best results, utilizing all the latest trends in iOS app...