如何从iOS上的代码中截取屏幕截图?

时间:2010-10-15 20:17:58

标签: ios iphone screenshot

如何从代码中截取屏幕截图?

1 个答案:

答案 0 :(得分:5)

http://www.iphonedevsdk.com/forum/iphone-sdk-development/2353-possible-make-screenshot-programmatically-2.html

#include <QuartzCore/QuartzCore.h>

UIGraphicsBeginImageContext(Background.bounds.size);
[Background.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);