代码之家  ›  专栏  ›  技术社区  ›  Ben Bar

与截图和文本一起共享URL

  •  0
  • Ben Bar  · 技术社区  · 9 年前

    我有一个很快的初学者问题:如何让这个函数也共享一个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)
    
    1 回复  |  直到 9 年前
        1
  •  0
  •   Bannings    9 年前

    只需添加一个 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)
    
    推荐文章