Skip to content

UIActivity subclass for copying link URL to pasteboard

Notifications You must be signed in to change notification settings

morishin/CopyLinkActivity

Repository files navigation

CopyLinkActivity

Swift version CocoaPods compatible Carthage compatible

UIActivity subclass for copying link URL to pasteboard

Usage

Example

import UIKit
import CopyLinkActivity

class ViewController: UIViewController {
    @IBAction func didTapShareButton(_ sender: UIButton) {
        let linkURL = URL(string: "https://www.apple.com/")!
        let activityViewController = UIActivityViewController(activityItems: [linkURL], applicationActivities: [CopyLinkActivity()])
        activityViewController.completionWithItemsHandler = { [weak self] (activityType, completed, _, _) -> Void in
            if completed && activityType == CopyLinkActivity.defaultActivityType {
                let alert = UIAlertController(title: "Copied", message: linkURL.absoluteString, preferredStyle: .alert)
                alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                self?.present(alert, animated: true)
            }
        }
        present(activityViewController, animated: true)
    }
}

Installation

Carthage

Cartfile

github "morishin/CopyLinkActivity"

CocoaPods

Podfile

pod 'CopyLinkActivity'

LICENSE

MIT

About

UIActivity subclass for copying link URL to pasteboard

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published