Swift:我想添加标签作为图像的叠加,然后我想将图像分享到社交网络

时间:2016-06-28 04:51:28

标签: ios swift uiimageview

Swift:我希望将标签添加为图像的叠加层,然后我想将图像分享到社交网络。

这是将图像分享给社交网络的代码..

@IBAction func share(sender: AnyObject) {

    let firstActivityItem = "Text you want"
    let secondActivityItem : NSURL = NSURL(string: "http//:www.google.com")!
    // If you want to put an image
    let image : UIImage = scannedImage.image!

    textToImage("gsdghdhfjhfhgdhdh", inImage: scannedImage.image!, atPoint: CGPointMake(20, 20))

    let activityViewController : UIActivityViewController = UIActivityViewController(
        activityItems: [firstActivityItem, secondActivityItem, image], applicationActivities: nil)

    // This lines is for the popover you need to show in iPad
    activityViewController.popoverPresentationController?.sourceView = (sender as! UIButton)

    // This line remove the arrow of the popover to show in iPad
    activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection()
    activityViewController.popoverPresentationController?.sourceRect = CGRect(x: 150, y: 150, width: 0, height: 0)

    // Anything you want to exclude
    activityViewController.excludedActivityTypes = [
          ]

    self.presentViewController(activityViewController, animated: true, completion: nil)

}

0 个答案:

没有答案