Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created October 14, 2017 15:00
Show Gist options
  • Save sjehutch/fb8982c6f355a805ff7911fa1d132576 to your computer and use it in GitHub Desktop.
Save sjehutch/fb8982c6f355a805ff7911fa1d132576 to your computer and use it in GitHub Desktop.
Swift Share Function
@IBAction func shareButtonClicked(_ sender: Any) {
let textToShare = "Check out my github repo!"
if let myWebsite = NSURL(string: "http://github.com/") {
let objectsToShare = [textToShare, myWebsite] as [Any]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = sender as? UIView
self.present(activityVC, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment