视频播放时如何拍摄截图?

时间:2012-06-29 06:45:02

标签: iphone

视频播放时如何拍摄屏幕截图?我使用MPMoviePlayerController进行视频播放。

1 个答案:

答案 0 :(得分:4)

- (UIImage *) captureScreen 
{
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    CGRect rect = [keyWindow bounds];
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [keyWindow.layer renderInContext:context];   
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}