特定Viewのスクリーンショットを撮る。
UIGraphicsBeginImageContextWithOptionsにスクリーンショットを撮る座標と縦横幅を指定する。よって対象のViewのframeを指定すればよい。
UIGraphicsBeginImageContextWithOptions(view.frame.size, false, 0.0) view.drawHierarchy(in: view.frame, afterScreenUpdates: true) let screenShotImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()! //スリーンショットがUIImage型で取得できる UIGraphicsEndImageContext()
リンク
リンク