本文介绍了在 iOS/swift 中获取当前屏幕的屏幕截图以进行共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的手机上启用一项功能,允许用户点击分享,然后他们就可以给他们的朋友发送一条消息,默认情况下包含应用程序的图片(就在用户点击分享之前).我不知道如何做到这一点 - 每当我搜索如何做到这一点时,我得到的都是关于如何在手机的照片库或通过他们的相机共享图像的教程/答案.关于如何做到这一点的任何想法!
I would like to enable a feature on my phone that allows users to click share, and then they would be able to text their friends a message that by default included a picture of the app (right before the user hit share). I cannot figure out how to do this - and whenever I search on how to do it all I get are tutorials/answers on how to share images in the phone's photo library or by their camera. Any idea on how to do this!
推荐答案//从截图创建图像
UIGraphicsBeginImageContext(view.frame.size) view.layer.renderInContext(UIGraphicsGetCurrentContext()) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()//分享图片
var imagesToShare = [AnyObject]() imagesToShare.append(image) let activityViewController = UIActivityViewController(activityItems: imagesToShare , applicationActivities: nil) activityViewController.popoverPresentationController?.sourceView = self.view presentViewController(activityViewController, animated: true, completion: nil)更多推荐
在 iOS/swift 中获取当前屏幕的屏幕截图以进行共享
发布评论