如何从相机视图拍摄屏幕截图?

时间:2012-04-09 01:52:14

标签: ios

朋友和先生

感谢您抽出时间给我。

我想在应用中拍摄屏幕截图。

现在我想尝试使用以下代码。

- (UIImage *)captureView:(UIView *)view {
    CGRect screenRect = [[UIScreen mainScreen] bounds];

    UIGraphicsBeginImageContext(screenRect.size);

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    [[UIColor blackColor] set];
    CGContextFillRect(ctx, screenRect);

    [view.layer renderInContext:ctx];

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return newImage;
}

但问题是,当我处于相机模式时,它只需要黑屏。

以上代码在除摄像机视图之外的其他视图中完美运行。

我想拍摄相机视图的截屏。

我可以使用UIGetScreenImage来获取相机视图的屏幕截图,但这是非公开的API,如果我使用它,则应用无法上传到xcode 4.3上的appstore。

我该怎么做?

对此有何想法?

如果那时这对我有很大的帮助。

再次感谢。

0 个答案:

没有答案
相关问题