ios编程:iPhone How-to:给UIView拍照
2012-04-26 15:04
513 查看
ios编程:iPhone How-to:给UIView拍照
时间:2011-04-22 csdn博客 林家男孩基本原理就是主要将UIView的layer描绘到图形上下文。UIView全局拍照和局域拍照的代码如下:
1 UIView全局拍照
- (UIImage *) screenImage:(UIView *)view { UIImage *screenImage; UIGraphicsBeginImageContext(view.frame.size); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; screenImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return screenImage; }
2 UIView局域拍照
- (UIImage *) screenImage:(UIView *)view rect:(CGRect)rect { CGPoint pt = rect.origin; UIImage *screenImage; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextConcatCTM(context, CGAffineTransformMakeTranslation(-(int)pt.x, -(int)pt.y)); [view.layer renderInContext:context]; screenImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return screenImage; }
来源:http://blog.csdn.net/lbj05/archive/2011/04/02/6297209.aspx
相关文章推荐
- ios编程:iPhone How-to:给UIView拍照
- iPhone How-to:给UIView拍照
- iPhone How-to:给UIView拍照
- [ios] How-to:给UIView拍照
- iPhone How-to:如何调整UIView的Z-Order
- [ios] How-to:给UIView拍照
- iPhone How-to:如何调整UIView的Z-Order
- iPhone How-to:如何递归dump UIView
- How to install IPA directly on your iOS! [iPhone/iPod/iPad]
- iPhone How-to:图片的灰度处理
- iPhone How-to:如何在NSDictionary中存放Selector
- how to debug EXC_BAD_ACCESS on iPhone
- iPhone How-to:图片的灰度处理
- How To Customise the Tab Bar (UITabBar) in an iPhone Application (Part 2 of 2)
- Documentation:Streaming HowTo/Streaming for the iPhone
- (iPhone/iPad开发)how to browse the document directory of iOS Devices
- [HOW TO]如何在iPhone应用程序中发送邮件
- iphone dev 入门实例7:How to Add Splash Screen in Your iOS App
- How to find crash logs for iPhone, iPod Touch or iPad applications
- iPhone How-to:播放gif动画