问题描述
我可以使用此代码裁剪视图
I'm able to crop a view with this code
- (UIImage *)captureScreenInRect:(CGRect)captureFrame {
CALayer *layer;
layer = self.view.layer;
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextClipToRect (UIGraphicsGetCurrentContext(),captureFrame);
[layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenImage;
}
但是我有一个imageview放大了transform,它没有显示
But I have an imageview zoomed in with transform and it isn't shown to scale.
如何准确捕获用户在屏幕上看到的内容
How do I capture EXACTLY what the user sees on the screen
推荐答案
堆栈溢出问题具有更多信息,但要点是:
The Stack Overflow question "renderInContext:" and CATransform3D has more info, but the gist is:
(摘自 )。
此技术问答中也提供了更多信息:
More info is also available in this technical Q&A: http://developer.apple.com/library/ios/#qa/qa1703/_index.html
如果您的应用程序不打算进入应用程序商店,则可以使用未记录的 UIGetScreenImage
API:
If your app is not going to the app store you can use the undocumented UIGetScreenImage
API:
// Define at top of implementation file
CGImageRef UIGetScreenImage(void);
...
- (void)buttonPressed:(UIButton *)button
{
// Capture screen here...
CGImageRef screen = UIGetScreenImage();
UIImage* image = [UIImage imageWithCGImage:screen];
CGImageRelease(screen);
// Save the captured image to photo album
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
(来自)
但是,使用此API会使您的应用未获得批准。
However, use of this API will make your app not get approved.
我找不到其他解决方法。
I have been unable to find any other workarounds.
这篇关于如何拍摄已变换视图的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!