iOS截图

葛智敏
2023-12-01
下面这个函数的代码,就是根据UIView上的 显示内容生成一张屏幕截图。值得注意的是,其中引用了Quartz2D中的函数,所以要使用的话要在文件头部增加一个引用。
#import QuartzCore/QuartzCore.h
-(UIImage *)getImageFromView:(UIView *)orgView{
UIGraphicsBeginImageContext(orgView.bounds.size); 
[orgView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); return image;
 类似资料: