如何在ios的屏幕上加载视频控制器的快照? [英] How to take snapshot of a viewcontroller without loading in screen in ios?

查看:124
本文介绍了如何在ios的屏幕上加载视频控制器的快照?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPAD应用程序中,我有两个viewcontrollers,第一个viewcontroller有一个按钮,我想点击那个按钮时得到第二个viewcontroler的快照,而不在iPAD屏幕中加载第二个viewcontroller 。
如果我加载viewcontroler然后拍摄快照然后它正在工作,但我的要求是在屏幕上加载viewcontroler时也这样做。
请提供想法或链接或代码段。

In my iPAD application, I have two viewcontrollers, first viewcontroller has a button, I want to get the snapshot of second viewcontroler when I click on that button, without loading the second viewcontroller in iPAD screen. If I load the viewcontroler and then take snapshot then it is working but my requirement is to do the same without loading the viewcontroler in screen. Please give idea or link or code snippet.

推荐答案

试试这个: -
制作VC的实例你想拍摄屏幕截图,然后用这个方法传递对象。

try this:- Make instance of VC that you want to take screen shot, and then pass the object in this method.

+ (UIImage *)renderImageFromView:(UIView *)view withRect:(CGRect)frame {
// Create a new context the size of the frame
UIGraphicsBeginImageContextWithOptions(frame.size, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();

// Render the view
[view.layer renderInContext:context];
//[view drawRect:frame];

// Get the image from the context
UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext();

// Cleanup the context you created
UIGraphicsEndImageContext();

return renderedImage;
}

这篇关于如何在ios的屏幕上加载视频控制器的快照?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆