我有一个非常快速的初学者问题:如何让此函数也共享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)
最佳答案
只需添加一个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)
关于xcode - 与截图和文本共享URL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32216505/