0
Xcode에서 지정된 지역 스크린 샷을 캡처하는 방법은 무엇입니까?Xcode의 지정된 지역 스크린 샷 캡처 방법
예를 들어, 화면에서 (0100320200)의 영역을 캡처하고 UIImage 객체에 저장 하시겠습니까?
감사
Xcode에서 지정된 지역 스크린 샷을 캡처하는 방법은 무엇입니까?Xcode의 지정된 지역 스크린 샷 캡처 방법
예를 들어, 화면에서 (0100320200)의 영역을 캡처하고 UIImage 객체에 저장 하시겠습니까?
감사
기본 해상도
CGRect rect = [captureView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
이 JPG에있는 UIImage 저장에이 코드 캡처에게 UIView의 시도 전체 화면 스크린 샷에 대한 다음 코드 (키 윈도우)
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGRect rect = [keyWindow bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
시도 형식으로 응용 프로그램의 문서 폴더에서 95 %의 품질로 할 수 있습니다.
NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/capturedImage.jpg"]];
[UIImageJPEGRepresentation(capturedImage, 0.95) writeToFile:imagePath atomically:YES];