A way to represent what you’re sharing.

Overview

VisualActivityViewController

Swift
Twitter

VisualActivityViewController Preview

About

This project provides a preview of items being shared via UIActivityViewController. Example:

// standard activity view controller
let vc = UIActivityViewController(activityItems: [shareText])

// custom activity view controller with a preview 
let vc = VisualActivityViewController(text: shareText)

Features

  • Text, Image, and URL previewing
  • Swipe gesture to dismiss the share sheet
  • Easy customization (match your app’s style)

Requirements

  • iOS 9.0+
  • Xcode 9.0+

Installation

To install, simply add the VisualActivityViewController.swift file to your project.

Advanced Usage

There are quite a few different options to customize the appearance of the preview. Check out the example project to see how some of these options work.

/// The duration for the preview fading in
var fadeInDuration: TimeInterval = 0.3

/// The duration for the preview fading out
var fadeOutDuration: TimeInterval = 0.3

/// The corner radius of the preview
var previewCornerRadius: CGFloat = 12

/// The corner radius of the preview image
var previewImageCornerRadius: CGFloat = 3

/// The side length of the preview image
var previewImageSideLength: CGFloat = 80

/// The padding around the preview
var previewPadding: CGFloat = 12

/// The number of lines to preview
var previewNumberOfLines: Int = 5

/// The preview color for URL activity items
var previewLinkColor: UIColor = UIColor(red: 0, green: 0.47, blue: 1, alpha: 1)

/// The font for the preview label
var previewFont: UIFont = UIFont.systemFont(ofSize: 18)

/// The margin from the top of the viewController's window
var previewTopMargin: CGFloat = 8

/// The margin from the top of the viewController's view
var previewBottomMargin: CGFloat = 8

License

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

Comments
  • Expose all properties in Objective C

    Expose all properties in Objective C

    Added @objcMembers prefix to class.

    This will expose the class properties to objective c, in the same way as they are exposed already in Swift.

    Closes issue #6

    opened by neilmorton 2
  • Expose all variables in Objective C

    Expose all variables in Objective C

    It would be extremely useful to expose all the variables to Objective C, as they are in Swift.

    Could be done using @objcMembers prefix to the VisualActivityViewController class.

    opened by neilmorton 1
  • Autoresizing Mask Autolayout error hides the Preview on iPad (works as expected on iPhone)

    Autoresizing Mask Autolayout error hides the Preview on iPad (works as expected on iPhone)

    Hello! I updated to the latest version, I'm getting a layout constraints error on iPad. The preview view doesn't display at all on iPad, and I'm guessing it's related to this error.

    My share items are a String and an URL.

    It works fine as expected on iPhone. Yes, I'm setting sourceRect and sourceView

    Here is the error:

    [LayoutConstraints] Unable to simultaneously satisfy constraints.
    	Probably at least one of the constraints in the following list is one you don't want. 
    	Try this: 
    		(1) look at each constraint and try to figure out which you don't expect; 
    		(2) find the code that added the unwanted constraint or constraints and fix it. 
    	(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
    (
        "<NSAutoresizingMaskLayoutConstraint:0x600001516620 h=--& v=--& UIView:0x7fbe60d56940.midY == 146   (active)>",
        "<NSAutoresizingMaskLayoutConstraint:0x60000150dae0 h=--& v=--& UIView:0x7fbe60d56940.height == 292   (active)>",
        "<NSLayoutConstraint:0x600001516080 UIVisualEffectView:0x7fbe60d56d40.top >= UILayoutGuide:0x600004f902a0'UIViewSafeAreaLayoutGuide'.top + 8   (active)>",
        "<NSLayoutConstraint:0x600001516cb0 UIVisualEffectView:0x7fbe60d56d40.bottom == UIView:0x7fbe60d56940.top - 8   (active)>",
        "<NSLayoutConstraint:0x6000015171b0 'UIViewSafeAreaLayoutGuide-top' V:|-(0)-[UILayoutGuide:0x600004f902a0'UIViewSafeAreaLayoutGuide']   (active, names: '|':UIView:0x7fbe6285b5c0 )>"
    )
    

    and here is my call

    let vc = VisualActivityViewController(activityItems: [shareText, url], applicationActivities: nil)
                                
    if let popoverPresentationController = vc.popoverPresentationController {
       popoverPresentationController.sourceRect = cell.bounds
       popoverPresentationController.sourceView = cell
    }
                                
    self.present(vc, animated: true, completion: nil)
    

    Thanks!

    opened by danramteke 1
  • applicationActivities

    applicationActivities

    Please add applicationActivities to VisualActivityViewController example : VisualActivityViewController(text: "", applicationActivities: Freedom.browsers())

    opened by Silent404 1
  • preview don't remove from window

    preview don't remove from window

    preview don't remove from window, will create constraint bug, I think you should remove it by this code;

     override func viewWillDisappear(_ animated: Bool) {
            super.viewWillDisappear(animated)
            UIView.animate(withDuration: fadeOutDuration) {
                self.preview?.alpha = 0
                if let window = self.view.window,
                    window.subviews.contains(self.preview) {
                    self.preview.removeFromSuperview()
                }
            }
        }
    
    opened by CivelXu 1
Owner
Ryan Ackermann
Jesus follower • Husband • Building @clay-inc • Writer @rwenderlich • Game Developer
Ryan Ackermann
iOS ReplayKit Screen Share Broadcast Extension Frame Sharing

An iOS app that demonstrates how we can share CMSampleBuffer frames from SampleHandler of Broadcast Extension to the host app and how to pass callbacks to and fro from host app to SampleHandler and vice versa.

IOTric 5 Oct 15, 2022
The Objective-C block utilities you always wish you had.

BlocksKit Blocks in C and Objective-C are downright magical. They make coding easier and potentially quicker, not to mention faster on the front end w

BlocksKit 6.9k Dec 28, 2022
Pavel Surový 0 Jan 1, 2022
The simplest way to display the librarie's licences used in your application.

Features • Usage • Translation • Customisation • Installation • License Display a screen with all licences used in your application can be painful to

Florian Gabach 51 Feb 28, 2022
The fastest 🚀 way to embed a 3D model in Swift

Insert3D is the easiest ?? and fastest ?? way to embed a 3D model in your iOS app. It combines SceneKit and Model I/O into a simple library for creati

Viktor Makarskyy 85 Dec 31, 2022
Simple way to set up half modal view

HalfModalView Requirements iOS 9.0+ Xcode 10.0+ Swift 4.0+ Example Installation CocoaPods is a dependency manager for Cocoa projects. You can install

Choi SeungMyeong 5 Nov 14, 2022
XCMetrics is the easiest way to collect Xcode build metrics and improve developer productivity.

XCMetrics is the easiest way to collect Xcode builds metrics and improve your developer productivity. Overview ?? Keep your build times under control

Spotify 989 Jan 2, 2023
Swordinator is a simple way of integrating an iOS Coordinator pattern.

Swordinator is a minimal, lightweight and easy customizable navigation framework for iOS applications. Requirements iOS 14.0+, Swift 5.0+ Installation

Timotheus Laubengaier 10 Oct 17, 2022
A declarative, thread safe, and reentrant way to define code that should only execute at most once over the lifetime of an object.

SwiftRunOnce SwiftRunOnce allows a developer to mark a block of logic as "one-time" code – code that will execute at most once over the lifetime of an

Thumbtack 8 Aug 17, 2022
A way to easily add Cocoapod licenses and App Version to your iOS App using the Settings Bundle

EasyAbout Requirements: cocoapods version 1.4.0 or above. Why you should use Well, it is always nice to give credit to the ones who helped you ?? Bonu

João Mourato 54 Apr 6, 2022
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift.

Easy way to detect device environment: Device model and version Screen resolution Interface orientation iOS version Battery state Environment Helps to

Anatoliy Voropay 582 Dec 25, 2022
A quick and "lean" way to swizzle methods for your Objective-C development needs.

Swizzlean A quick and "lean" way to swizzle methods for your Objective-C development needs. Adding Swizzlean to your project Cocoapods CocoaPods is th

Ryan Baumbach 104 Oct 11, 2022
Testable Combine Publishers - An easy, declarative way to unit test Combine Publishers in Swift

Testable Combine Publishers An easy, declarative way to unit test Combine Publishers in Swift About Combine Publishers are notoriously verbose to unit

Albert Bori 6 Sep 26, 2022
Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm

Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm. Creating a chan

Christoffer Winterkvist 127 Jun 3, 2022
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.

Introduction EtherWalletKit is an Ethereum Wallet Toolkit for iOS. I hope cryptocurrency and decentralized token economy become more widely adapted. H

Sung Woo Chang 136 Dec 25, 2022
LifetimeTracker can surface retain cycle / memory issues right as you develop your application

LifetimeTracker Bar style Circular style LifetimeTracker can surface retain cycle / memory issues right as you develop your application, and it will s

Krzysztof Zabłocki 2.8k Jan 4, 2023
WhatsNewKit enables you to easily showcase your awesome new app features.

WhatsNewKit enables you to easily showcase your awesome new app features. It's designed from the ground up to be fully customized to your needs. Featu

Sven Tiigi 2.8k Jan 3, 2023
Extensions that allow you to work with optionals

RxOptionals Sometimes it happens that you need to bind to several optional binders or to an optional method (for example, when using weak). To do this

Dane4ka 3 Aug 9, 2021