+(UIImage*) imageByCaptureScreen {
if(UIGraphicsBeginImageContextWithOptions!=NULL)
{
UIGraphicsBeginImageContextWithOptions([UIScreenmainScreen].bounds.size,NO,0);
}
else
{
UIGraphicsBeginImageContext([UIScreenmainScreen].bounds.size);
}
CGContextRefcontext =UIGraphicsGetCurrentContext();
for(UIWindow*windowin[[UIApplicationsharedApplication]windows])
{
if(![windowrespondsToSelector:@selector(screen)] || [windowscreen] == [UIScreenmainScreen])
{
CGContextSaveGState(context);
CGContextTranslateCTM(context, [windowcenter].x, [windowcenter].y);
CGContextConcatCTM(context, [windowtransform]);
if(IOS7_OR_LATER)
{
CGContextTranslateCTM(context,
-[windowbounds].size.width* [[windowlayer]anchorPoint].x,
-[windowbounds].size.height* [[windowlayer]anchorPoint].y);
}
else
{
CGContextTranslateCTM(context,
-[windowbounds].size.width* [[windowlayer]anchorPoint].x,
-[windowbounds].size.height* [[windowlayer]anchorPoint].y-20);
}
[[windowlayer]renderInContext:context];
CGContextRestoreGState(context);
}
}
UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnimage;
}
iOS截取整个屏幕
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 苏轼说过:腹有诗书气自华,读书万卷始通神。读书可以增加见识,陶冶情操,提高个人修养,所以读书对我们有着巨大意...