2011-09-12 7 views
0

프로그래밍 방식으로 스크린 샷을 찍어 전자 메일로 보내려고합니다. 이 작업을 수행 할 수는 있지만 전자 메일과 함께 첨부 된 전체 스크린 샷을 보내고 있지만 보낼 스크린 샷을 자르고 싶습니다. 어떻게해야합니까? 제게이 제안을하십시오.자르기 스크린 샷 프로그래밍 방식

다음은 스크린 샷을 촬영하기위한 코드입니다.

UIGraphicsBeginImageContext(self.view.bounds.size); 
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

답변

3

여기에서 아래에서 스크린 샷을 자르기 위해 사용했습니다. -40은 아래에서 40 픽셀 씩 자르기 스크린 샷입니다.

UIGraphicsBeginImageContext(self.view.bounds.size); 
CGContextRef c = UIGraphicsGetCurrentContext(); 
CGContextTranslateCTM(c,-40,0); // <-- shift everything up by 40px when drawing. 
[self.view.layer renderInContext:c]; 
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext();