1
以下、私はscreenShot関数が私のviewControllerの完全なスクリーンショットをとるようにコーディングしようとしました。どのようにスクリーンショットを撮ってsharePressedアクションのactivityItemsに入れることができるかを把握しようとしているので、共有しようとするとスクリーンショットが表示されます。共有ボタンでスクリーンショットを取得して表示するにはどうすればよいですか?
func captureScreen() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale)
view.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
@IBAction func sharePressed(_ sender: Any) {
let activityVC = UIActivityViewController(activityItems: [""], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.view
self.present(activityVC, animated: true, completion: nil)
}
このリンクを見 https://stackoverflow.com/questions/30876068/what-is-in-swift-telling-me/30876177 –