Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 为UIImageView拍摄屏幕快照_Iphone_Objective C_Ios_Screen Capture - Fatal编程技术网

Iphone 为UIImageView拍摄屏幕快照

Iphone 为UIImageView拍摄屏幕快照,iphone,objective-c,ios,screen-capture,Iphone,Objective C,Ios,Screen Capture,我想为我视图中的特定部分拍摄屏幕截图(具体来说是图像视图),是否有机会……您似乎需要执行renderInContext // Size of the result rendered image CGSize targetImageSize = CGSizeMake(100, 100); // Check for retina image rendering option if (NULL != UIGraphicsBeginImageContextWithOptions) UIGraphicsB

我想为我视图中的特定部分拍摄屏幕截图(具体来说是图像视图),是否有机会……

您似乎需要执行
renderInContext

// Size of the result rendered image
CGSize targetImageSize = CGSizeMake(100, 100);
// Check for retina image rendering option
if (NULL != UIGraphicsBeginImageContextWithOptions) UIGraphicsBeginImageContextWithOptions(targetImageSize, NO, 0);
else UIGraphicsBeginImageContext(targetImageSize);

CGContextRef context = UIGraphicsGetCurrentContext();
// The view to be rendered
[[yourImageView layer] renderInContext:context];
// Get the rendered image
UIImage *original_image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

您要拍摄图像视图的屏幕截图还是图像视图的屏幕截图。我很欣赏你的英语可能不太好,但两者(of和for)是有区别的,取决于你的意思,答案会有所不同。例如,如果您试图拍摄图像视图的屏幕截图,为什么不在图像视图中使用图像,而不是尝试截图呢?对不起,图像视图的屏幕截图谢谢您的代码。我想我的问题不太明确,我正在一个接一个地使用两个图像视图。我想拍摄两个图像视图的屏幕截图。是的。在UIView上添加这两个图像视图,并渲染该视图。假设UiImageView的大小为768x1024,我需要拍摄以UiImageView中心为中心的200x200矩形的屏幕截图。我需要先翻译CTM吗?