使用腾讯云的截屏功能

使用腾讯的方法只有图片没有文字

- (void)snapshotLocalVideo {
    WS(weakSelf);
    [self.settingsManager.trtc snapshotVideo:nil
                                        type:TRTCVideoStreamTypeBig
                             completionBlock:^(TXImage *image) {
        if (image) {
            
            UIImageWriteToSavedPhotosAlbum(image, weakSelf, @selector(image:didFinishSavingWithError:contextInfo:), nil);

        }
    }];
}

使用系统截屏只有文字没有图片

-(UIImage *)captureImageFromView:(UIView *)view{
    UIGraphicsBeginImageContextWithOptions(self.view.frame.size,NO, 0);
    [[UIColor clearColor] setFill];
    [[UIBezierPath bezierPathWithRect:self.view.bounds] fill];
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:ctx];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
    
}

使用下面的方法可以解决该问题

UIWindow *mainWindow = [UIApplication sharedApplication].keyWindow;
    UIGraphicsBeginImageContextWithOptions(mainWindow.frame.size, NO, 0);
    [mainWindow drawViewHierarchyInRect:mainWindow.frame afterScreenUpdates:YES];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

你可能感兴趣的:(使用腾讯云的截屏功能)