iOS屏幕截图
2015-11-20 11:10
543 查看
//获得屏幕图像
- (UIImage *)imageFromView: (UIView *) theView{
UIGraphicsBeginImageContext(theView.frame.size);
CGContextRef
context = UIGraphicsGetCurrentContext();
[theView.layer renderInContext:context];
UIImage *
theImage= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
//获得某个范围内的屏幕图像
- (UIImage *)imageFromView: (UIView *) theView atFrame:(CGRect)r
{
UIGraphicsBeginImageContext(theView.frame.size);
CGContextRef
context= UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
UIRectClip(r);
[theView.layer renderInContext:context];
UIImage *
theImage= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;//[self getImageAreaFromImage:theImage atFrame:r];
}
相关文章推荐
- iOS开发----关于导航条的研究
- SVN(Subversion)
- 详述iOS国际化
- IOS打电话代码实战
- iOS 采用个推时,未收到推送消息,测试DeviceToken无效
- 在Xcode6中添加Precompile Prefix Header
- iOS学习笔记47-iOS开发总结之代码规范
- iOS中Bitcode的介绍及配置
- iOS远程推送原理流程图
- IOS常用宏定义
- ios view的frame和bounds之区别(位置和大小)
- iOS学笔记本46-iOS自定义转场
- iOS 第三方登录之 新浪微博登录
- iOS类归档,zip压缩。
- 详解 iOS 上机题!附个人见解
- 【译】详细讲述iOS自定义转场
- iOS/OS X内存管理(二):借助工具解决内存问题
- 17个提升iOS开发效率的必用工具
- iOS 快速集成ShareSDK实现分享功能
- #if 0 ... #endif的真实用途