我想在我的视图中拍摄特定部分的屏幕截图(具体来说是一个imageview),有没有机会......
答案 0 :(得分:3)
您似乎需要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();