0
A
回答
4
尝试使用全屏幕截图下面的代码(键窗口)
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();
试试这个代码捕获一个UIView在原始分辨率
CGRect rect = [captureView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
这节省了UIImage的在JPG格式与95%的质量在应用程序的文档文件夹,如果你需要这样做。
NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/capturedImage.jpg"]];
[UIImageJPEGRepresentation(capturedImage, 0.95) writeToFile:imagePath atomically:YES];
相关问题
- 1. ASP.NET - 获取屏幕特定区域的屏幕截图?
- 2. 捕获屏幕截图
- 3. 捕获MKMapView屏幕截图
- 4. ASP.NET - 捕获屏幕截图
- 5. 捕获屏幕截图
- 6. 屏幕捕获OCR屏幕的特定区域
- 7. iPhone屏幕截图特定区域
- 8. 使用ScreenCapture捕获屏幕截图并捕获屏幕截图.CaptureScreenshot
- 9. 捕捉屏幕的区域
- 10. SpriteKit屏幕截图的屏幕截图
- 11. 在硒中捕获屏幕截图
- 12. 捕获屏幕截图的iframe
- 13. 将屏幕截图捕捉到屏幕上时不起作用
- 14. 桌面屏幕捕获目标区域
- 15. 捕获屏幕截图 - html2canvas不工作
- 16. 用ImageMagick ++捕获X11屏幕截图
- 17. 如何在iPhone上使用UI自动捕获屏幕截图?
- 18. 如何创建特定区域的屏幕截图?
- 19. 屏幕截图
- 20. 屏幕捕获的代码屏幕捕获Android的任何屏幕
- 21. 以当前屏幕的屏幕截图
- 22. 以整个屏幕的屏幕截图
- 23. 屏幕部分的屏幕截图
- 24. 捕获屏幕
- 25. 捕获屏幕
- 26. osx上的屏幕截图
- 27. iPhone上的屏幕截图
- 28. 屏幕截图到任何屏幕(Android Root,就像屏幕截图UX)
- 29. 登录屏幕中的屏幕捕获
- 30. 如何获取屏幕截图图片