Skip to content

Commit

Permalink
Comment: 스크린샷 코드 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
JMM00 committed Sep 30, 2022
1 parent e3a523f commit 8922b98
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions Model/Screenshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ import SwiftUI
// MARK: - 이미지 저장 기능을 위한 확장
extension View {

//화면에 보이는 그대로를 캡쳐
func screenshot() -> UIImage {

var image: UIImage?
let scenes = UIApplication.shared.connectedScenes
let windowScenes = scenes.first as? UIWindowScene
guard let currentView = windowScenes?.windows.first(where: { $0.isKeyWindow })?.layer else { return UIImage() }
let screenScale = UIScreen.main.scale

// image capture
UIGraphicsBeginImageContextWithOptions(currentView.frame.size, false, screenScale)
guard let currentContext = UIGraphicsGetCurrentContext() else { return UIImage() }
currentView.render(in: currentContext)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

// crop image
let cropRect: CGRect = .init(origin: CGPoint(x: 0, y: 250), size: CGSize(width: 1500 , height: 2000))
let imageRef = image!.cgImage!.cropping(to: cropRect);
let newImage = UIImage(cgImage: imageRef!, scale: image!.scale, orientation: image!.imageOrientation)

return newImage
}
//UIView를 캡쳐
func snapShot() -> UIImage {
let controller = UIHostingController(rootView: self)
Expand Down

0 comments on commit 8922b98

Please sign in to comment.