使用腾讯云的截屏功能

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

- (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();
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容