0

I have a very quick beginners question: How can i have this function share a URL as well? I always follow everything and think i got it right, but it doesn't quite seem to work... Thanks a lot in advance!

func takeSnapshot(view: UIView) {
    let bounds = UIScreen.mainScreen().bounds
    UIGraphicsBeginImageContextWithOptions(bounds.size, true, 0.0)
    self.view.drawViewHierarchyInRect(bounds, afterScreenUpdates: false)
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    let text = "Text to be shared... #Hashtag"
    let activityViewController = UIActivityViewController(activityItems: [image, text], applicationActivities: nil)
    self.presentViewController(activityViewController, animated: true, completion: nil)
Ben Bar
  • 75
  • 1
  • 3

1 Answers1

0

Just add an NSURL:

let bounds = UIScreen.mainScreen().bounds
UIGraphicsBeginImageContextWithOptions(bounds.size, true, 0.0)
self.view.drawViewHierarchyInRect(bounds, afterScreenUpdates: false)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let text = "Text to be shared... #Hashtag"
let URL = NSURL(string: "http://stackoverflow.com/")!

let activityViewController = UIActivityViewController(activityItems: [image, text, URL], applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
Bannings
  • 10,376
  • 7
  • 44
  • 54