无法捕获iCarousel的全屏

时间:2014-02-21 08:15:09

标签: ios objective-c

我有一个问题是捕获iCarousel的全屏。它只能捕获Carousel的索引。

    UIGraphicsBeginImageContext(caputureView.bounds.size);
    [caputureView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

- (void) getFullScreenScreenShot
{
    AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    UIView* superView = appDelegate.viewController.view;
    CGRect fullScreenFrame = superView.frame;
    UIGraphicsBeginImageContextWithOptions(fullScreenFrame.size, YES, 0.0f);
    CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0.0f, 0.0f);
    [superView.layer renderInContext: UIGraphicsGetCurrentContext()];
    UIImageView* screenShot = [[UIImageView alloc] initWithImage: UIGraphicsGetImageFromCurrentImageContext()];
    UIGraphicsEndImageContext();
    NSData* imageData = UIImageJPEGRepresentation(screenShot.image, 1.0);
    NSString* previewFileNamePath = [[CPFileManager documentsPath] stringByAppendingString: @"image.jpg"];

    if ([imageData writeToFile: previewFileNamePath
                    atomically: NO])
    {
        NSLog(@"See filename:%@", previewFileNamePath);
    }
    else
    {
        NSLog(@"Error: %@", previewFileNamePath);
    }
}