0
votes

I have one image generate it in App

the image displayed in uiimageview

here is my image

var img:UIImage!
img = UIImage(ciImage: transformedImage)

here is the value before share it in breakpoint

print(img)

some(UIImage: 12345 , {200, 200})

let myShare = "My beautiful photo! <3 <3"


let shareVC: UIActivityViewController = UIActivityViewController(activityItems: [(img), myShare], applicationActivities: nil)
self.present(shareVC, animated: true, completion: nil)

but the image can not be show but the text it's show in iMessage or email and other apps ... How can I share the image ? in iMessage emails and etc...

1

1 Answers

0
votes

Use this method:

func shareImageBtn(img : UIImage, txt : String) {
// if an image and a txt aren't nil
        let resourses = [ image!, txt!]
        let activityViewController = UIActivityViewController(activityItems: resources, applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // iPads won't crash

        // (optional)
        activityViewController.excludedActivityTypes = [ .airDrop, .postToFacebook ]

        // present the VC
        self.present(activityViewController, animated: true, completion: nil)
    }