2017-04-12 1 views
1

나는 현재 내가 가지고있는 스크린 캡쳐를 얻으려고하고 있는데, 다음 뷰 컨트롤러를 오버레이 할 때 그 뒤에 이미지 뷰를 만들 수 있고 반투명 한 것처럼 보이게 할 수있다. . 이것은 작동하지만 지금은 중간에 이상한 회색을 만듭니다. 여기에 내가 사용하고있는 코드입니다 : 여기화면 캡쳐 - 기이 한 회색 영역

func requestOverride(overrideReason : String, notificationName : Notification.Name) { 

    captureScreen { (image) in 
     ManagerOverride.image = image 

     let vc = UIStoryboard(name: "ManagerOverride", bundle: nil).instantiateViewController(withIdentifier: "overrideNav") as! UINavigationController 
     let over = vc.viewControllers.first as! ManagerOverrideViewController 
     let _ = over.view 
     over.overrideReason.text = overrideReason 
     over.notifyName = notificationName 
     UIApplication.shared.keyWindow?.currentViewController()?.present(vc, animated: true, completion: nil) 
    } 
} 

func captureScreen(completion: @escaping (UIImage) ->()) { 
let view = UIApplication.shared.keyWindow!.currentViewController()!.view! 
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale) 
view.layer.render(in: UIGraphicsGetCurrentContext()!) 
let image = UIGraphicsGetImageFromCurrentImageContext() 
UIGraphicsEndImageContext() 
completion(image!) 
} 

하고 있는지 내가 다시 점점 오전 :

나는 그것의 맥락에서

답변

0

렌더링 전망이라고하고 왜 아무 생각이 없다 불행히도 100 % 방법이 아닙니다. 모든보기 및 레이어 속성이 스크린 샷에 저장되는 것은 아닙니다. 제가 알고있는 것은 layer.mask입니다 (또는 잠재적으로 masksToBounds 플래그 상태). 이것은 당신의 문제일지도 모르고, 몇몇보기는 가면을 사용하고, 화면에는 가면이 보이지만, 거기에 마스크가없는 것처럼 렌더링됩니다.