0

我有一个非常快速的初学者问题:我怎样才能让这个函数也共享一个 URL?我总是遵循一切并认为我做对了,但它似乎并不完全有效......提前非常感谢!

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)
4

1 回答 1

0

只需添加一个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)
于 2015-08-26T03:46:29.727 回答