保存全屏为image
2016-06-30 10:46
316 查看
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
UIGraphicsBeginImageContextWithOptions(imageSize, NO,
0);
CGContextRef context =
UIGraphicsGetCurrentContext();
for (UIWindow * window
in [[UIApplication sharedApplication] windows]) {
if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) {
CGContextSaveGState(context);
CGContextTranslateCTM(context, [window center].x, [window center].y);
CGContextConcatCTM(context, [window transform]);
CGContextTranslateCTM(context, -[window bounds].size.width*[[window layer] anchorPoint].x, -[window bounds].size.height*[[window layer] anchorPoint].y);
[[window layer] renderInContext:context];
CGContextRestoreGState(context);
}
}
UIImage *image =
UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsBeginImageContextWithOptions(imageSize, NO,
0);
CGContextRef context =
UIGraphicsGetCurrentContext();
for (UIWindow * window
in [[UIApplication sharedApplication] windows]) {
if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) {
CGContextSaveGState(context);
CGContextTranslateCTM(context, [window center].x, [window center].y);
CGContextConcatCTM(context, [window transform]);
CGContextTranslateCTM(context, -[window bounds].size.width*[[window layer] anchorPoint].x, -[window bounds].size.height*[[window layer] anchorPoint].y);
[[window layer] renderInContext:context];
CGContextRestoreGState(context);
}
}
UIImage *image =
UIGraphicsGetImageFromCurrentImageContext();
相关文章推荐
- GreenDao的简单使用说明(六)补遗
- mysql 性能优化索引、缓存、分表、分布式实现方式。
- .NET Web开发技术简单整理
- IE中的ActiveXObject对象-基础
- (一)Spring4.0初步认识
- Eclipse 安装Web Service、Axis2插件
- 飞机爆炸效果
- 原理分析:从JDBC到Mybatis
- ajax请求
- 两点之间的距离
- 【WPF】Combobox指定选中值用selectedValue不是很灵的时候,
- javascript的settimeout和异步
- raw socket使用
- GreenDao的简单使用说明(五)多表n:m
- php中pdo使用sqlite3连接的配置例子
- C++ 在继承中虚函数、纯虚函数、普通函数,三者的区别
- Poj 2524 Ubiquitous Religions
- centos 设置oracle 开机自启动
- ActivityViewController 使用AirDrop分享
- 使用Mybatis Generator结合Ant脚本快速自动生成Model、Mapper等文件的方法