截屏
2016-04-01 15:08
120 查看
/** 截屏*/
- (UIImage *)getSnapshotImage {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)), NO, 1);
[self.view drawViewHierarchyInRect:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) afterScreenUpdates:NO];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshot;
}
/** 截取屏幕包括导航条*/
- (UIImage*)screenView:(UIView *)view{
CGRect rect = view.frame;
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
- (UIImage *)getSnapshotImage {
UIGraphicsBeginImageContextWithOptions(CGSizeMake(CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)), NO, 1);
[self.view drawViewHierarchyInRect:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) afterScreenUpdates:NO];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshot;
}
/** 截取屏幕包括导航条*/
- (UIImage*)screenView:(UIView *)view{
CGRect rect = view.frame;
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
相关文章推荐
- 对于PostgreSQL中Datum的解释
- javascript学习(10)——[知识储备]链式调用
- c++ Jsoncpp的安装及Json的解析和创建
- iOS Swift编程语言
- java邮件发送
- 认识JavaScript的原型
- 腾信微信公众号初步开发应用
- 根据文件名或文件扩展名获取文件的默认图标
- App 分发到企业平台下载
- 时间戳
- Java垃圾回收机制_你不知道的GC_转深度好文
- Java实现大整数相加
- Android入门——Drawable与对应的资源xml的应用
- lua 中操作系统库
- 1031. 查验身份证
- 写博客的重要性
- 自定义view 落叶效果
- 获取程序路径
- Unity中NGUI出现边缘线条的解决办法
- unity3d的playmaker插件使用教程,六、血量显示及处理