1

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

4

1 回答 1

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;
}
于 2012-06-29T06:54:06.950 回答