A UIActivityViewController to share images while displaying them as a nice preview.

Overview

PSActivityImageViewController

Overview

This view controller allows you to share an image the same way as a normal UIActivityViewController would, with one bonus: The image is actually shown on top of the UIActivityViewController with a nice blurred background.

You can add any items you want to share, but only the image is displayed.

Screenshots

These screenshots are taken from my app TwoSlideOver. Check it out here

Videos

Input

  • image: The image you want to share and at the same time display as a preview.
  • activityItems: All the items you want to share, with the image included.
  • completion: An optional UIActivityViewController.CompletionWithItemsHandler to handle any code after completion.

Usage

import PSActivityImageViewController

...

let activityImageVC = ActivityImageViewController(
   image: someImage,
   activityItems: [someImage, self], // or just [someImage]
   completion: { activity, completed, _, error in

       if let error = error {
           print("Error: \(error.localizedDescription)")
           return
       }

       // Do something with the rest of the information.
   }
)

// Important for iPad, as otherwise the app will crash!
activityImageVC.popoverPresentationController?.sourceView = someView
activityImageVC.popoverPresentationController?.sourceRect = someView.bounds

present(activityImageVC, animated: true)

Warning

As is the case for UIActivityViewController, on iPad you need to specify the source for the popoverPresentationController.

Installation

Swift Package Manager

PSActivityImageViewController is available through Swift Package Manager.

Add it to an existing Xcode project as a package dependency:

  1. From the File menu, select Swift Packages › Add Package Dependency…
  2. Enter "https://github.com/psalzAppDev/PSActivityImageViewController" into the package repository URL text field

Requirements

  • iOS 10.0+
  • Xcode 12+

License

PSActivityImageViewController is available under the MIT license. See the LICENSE file for more info.

You might also like...
App that generates random images and attempts to classify them with MobileNetV2
App that generates random images and attempts to classify them with MobileNetV2

Image-Classifier-App App that generates random images and attempts to classify t

WhiteAndFluffyTest - Scroll images and add them to your favourites via image page
WhiteAndFluffyTest - Scroll images and add them to your favourites via image page

Image service application Scroll images and add them to your favourites via imag

Highly customizable Action Sheet Controller with Assets Preview written in Swift
Highly customizable Action Sheet Controller with Assets Preview written in Swift

PPAssetsActionController Play with me ▶️ 🖐 If you want to play with me, just tap here and enjoy! 🎩 🕴 Show me 🎪 Try me 📲 The easiest way to try me

SwiftUI  project to show ActivityIndicator above Image while loading
SwiftUI project to show ActivityIndicator above Image while loading

ImageWithActivityIndicatorDemo SwiftUI project to show ActivityIndicator above Image while loading ImageWithActivityIndicatorDemo is a demo app that s

Microblog-ref-app - A Twitter like social media app that users can share their moments
Microblog-ref-app - A Twitter like social media app that users can share their moments

HiPlace - iOS Table of Contents Introduction HMS Services Getting Started Suppor

Metazoom - A virtual camera plugin to pixellatedly share your screen

MetaZoom A virtual camera plugin to pixellatedly share your screen. See LICENSE.

Space! – an iOS widget displaying NASA's Astronomy Picture of the Day
Space! – an iOS widget displaying NASA's Astronomy Picture of the Day

Space! NASA's Astronomy Picture of the Day – now on your Home Screen with widgets! Space! displays the latest APOD photo curated by NASA every day. Se

A SwiftUI view for displaying image histograms
A SwiftUI view for displaying image histograms

HistogramView A SwiftUI view for displaying image histograms. How do I use it? It's as simple as: HistogramView(image: myImage) Note: Both UIImage & N

IBrain - Displaying a Point Cloud Using Scene Depth
IBrain - Displaying a Point Cloud Using Scene Depth

Displaying a Point Cloud Using Scene Depth Present a visualization of the physic

Comments
  • Command CompileSwiftSources failed when exporting localizations in XCode

    Command CompileSwiftSources failed when exporting localizations in XCode

    Hi Peter,

    It's me again.

    When having your package added to my project, everything works out fine and also builds, but:

    When I try to export localized resources (the new SwiftUI feature) via Product->Export Localizations... in Xcode, the project won't build and logs say "Command CompileSwiftSources failed". If I remove the PSActivityImageViewController dependency, everything works fine (when exporting). For my project in general I had to set Use compiler to Extract Swift Strings to YES in order to get this export process to work (the default value is NO). Maybe, there is some misconfiguration for your package? To be honest, I can't find it at the moment. Compiler complains about multiple issues in ActivityImageView.swift file. Errors like Cannot find View in scope in line 13. Could this belong to the #if canImport(SwiftUI) line? Really, I'm not sure.

    Note/EDIT: The problem seems to be independent of the https://github.com/SwiftUI-Plus/ActivityView package because it builds (when exporting localizations as described above) without issues. Just when adding the PSActivityImageViewController package, I get problems as described. Hmm...

    Thomas

    bug 
    opened by tomsun3 3
  • Using/Sharing UIImage?

    Using/Sharing UIImage?

    Thanks a lot for this library! Looks very promising. I just tried: when using an UIKit UIImage (which I have) and converting it to a SwiftUI Image and adding it as image to the ActivityImageItem, the image is not displayed correctly (for some reason, it's moved 50% up and to the left, so we only see a quarter of the image in the top-left quarter). Am I doing something wrong or is there an internal problem?

    Thanks a lot in advance Peter!

    I'm using SwiftUI and this is the relevant code on share button click:

    let img = Image(uiImage: theOriginalUiImage)
    shareActivityItem = ActivityImageItem(image: img)
    
    bug 
    opened by tomsun3 3
Releases(1.1.3)
Owner
Peter Salz
Peter Salz
SwiftUI view that download and display image from URL and displaying Activity Indicator while loading .

ViewWithActivityIndicator ViewWithActivityIndicator is a SwiftUI view that download and display image from URL and displaying Activity Indicator while

Ali Adam 28 Feb 3, 2022
iOS Framework that makes it easy to preview images on any UIImageView.

AZImagePreview iOS Framework that makes it easy to preview images on any UIImageView. Screenshots Installation: Cocoa Pods: pod 'AZImagePreview' Swift

Antonio Zaitoun 25 Dec 11, 2022
iOS SDK to share JPEG images with an expiration date

Ebblink iOS SDK A library to integrate Ebblink private image sharing capabilities into your iOS app. Table of Contents Getting Started Requirements Se

null 4 Apr 6, 2018
APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built on top of a modified version of libpng wit

Wei Wang 2.1k Dec 30, 2022
Advanced framework for loading, caching, processing, displaying and preheating images.

Advanced framework for loading, caching, processing, displaying and preheating images. This framework is no longer maintained. Programming in Swift? C

Alexander Grebenyuk 1.2k Dec 23, 2022
ImageView - Component for loading and displaying different images aka SVG/PNG/JPG/JPEG

ImageView Component that loads and displays images(.svg/.png/.jpg/.jpeg) form as

Sergei 1 Mar 23, 2022
A Swift/SwiftUI utility for caching and displaying images in SwiftUI Views

A Swift/SwiftUI utility for caching and displaying images asynchronously. Built with Swift 5.5 and works with async/await.

王雪铮 Xuezheng Wang 1 May 5, 2022
SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them type-safe to use.

SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them type-safe to use.

null 8.3k Jan 5, 2023
Jogendra 113 Nov 28, 2022
Style Art library process images using COREML with a set of pre trained machine learning models and convert them to Art style.

StyleArt Style Art is a library that process images using COREML with a set of pre trained machine learning models and convert them to Art style. Prev

iLeaf Solutions Pvt. Ltd. 222 Dec 17, 2022