このようにして画面の一部をスクショ撮る時、撮る場所を上から〜px、左横から〜pxなど変えたい場合はどのようにすればいいですか?
//画像を保存するためのメゾット @IBAction func savePhoto(){ //画面上のスクリーンショットを取得 let rect:CGRect = CGRect(x: 0, y: 0, width: 320, height: 340) UIGraphicsBeginImageContext(rect.size) self.view.layer.render(in: UIGraphicsGetCurrentContext()!) let capture = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() //カメラロールに保存 UIImageWriteToSavedPhotosAlbum(capture!, nil, nil, nil) }
追記、自分で調べてみてもよくわからなかったため質問させていただきました。
あなたの回答
tips
プレビュー