标签:
一 实例方法(将当前view转换成一张图片)
- (UIImage *)convertViewToImage
{
UIGraphicsBeginImageContext(self.bounds.size);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenshot;
}
二 类方法(将当前view转换成一张图片)
+(UIImage*)captureScreen
{
extern CGImageRef UIGetScreenImage();
CGImageRef screen=UIGetScreenImage();
UIImage* newImage=[UIImage imageWithCGImage:screen];
return newImage;
}
标签:
原文地址:http://my.oschina.net/iOSliuhui/blog/509028