iOS截图

-(void)touchesEnded:(NSSet *)touches
withEvent:(UIEvent *)event

{

//    1.开始图形上下文

CGSize imageSize = self.view.bounds.size;

UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0);

//2.将某个view的所有内容渲染到图形上下文中

CGContextRef  contextRef = UIGraphicsGetCurrentContext();

[self.view.layer renderInContext:contextRef];

//3.取的图片

UIImage * image = UIGraphicsGetImageFromCurrentImageContext();

CGImageRef subImage = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, 0, self.view.bounds.size.width * 0.9, self.view.bounds.size.height));

UIImage * newImage = [UIImage imageWithCGImage:subImage];

//写入本地文件

[UIImagePNGRepresentation(newImage) writeToFile:@"/Users/Lenny/Desktop/view.png"  atomically:YES];

//结束图形上下文

UIGraphicsEndImageContext();

}

时间: 2024-10-12 17:15:40

iOS截图的相关文章

iOS 截图

UIView截图 - (UIImage *)captureView:(UIView *)theView { CGRect rect = theView.frame; if ([theView isKindOfClass:[UIScrollView class]]) { rect.size = ((UIScrollView *)theView).contentSize; } UIGraphicsBeginImageContext(rect.size); CGContextRef context =

iOS截图功能

-(UIImage *)captureScreenWithRect:(CGRect)rect{ UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 1); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIImag

【1】【IOS】 截图

1 UIGraphicsBeginImageContext(self.view.bounds.size);// 设置上下文 2 3 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];4 5 UIImage *image=UIGraphicsGetImageFromCurrentImageContext();//从当前上下文中获取image 6 7 UIGraphicsEndImageContext();//关闭上下文

IOS VLC编译步骤(包含移植和截图功能)

http://blog.csdn.net/Kan_Crystal/article/details/40424673 一.下载源码 先到VLC官网将源码下载到本机,以下链接为官网编译操作地址:https://wiki.videolan.org/IOSCompile/ 将终端打开执行以下命令 (建议使用VPN) : git clone git://git.videolan.org/vlc-ports/ios.git 代码下载完成后将对代码进行编译: (Release):sh compileVLCfo

IOS截屏,View截图的基本方法

IOS截屏的方法网上有很多,以下是我个人认为比较好的一个,我稍微改了一点 来源:SDScreenshotCapture #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) UIImage *getImageWithFullScreenshot(vo

李洪强iOS开发之苹果使用预览截图

李洪强iOS开发之苹果使用预览截图 01 在预览的图片中选中你要截得区域  02 - command + C   03 - Command + N 04 - Command + S (保存)

IOS批量截取视频截图 UIImage mp4 IOS Video

IOS批量截取视频截图 //生成截图 NSString *path = [NSHomeDirectory() stringByAppendingString:@"/Documents"]; NSLog(@"path %@", path); for (int i = 0; i<[mItems count]; i++) { NSMutableDictionary *info = (NSMutableDictionary *)mItems[i]; //视频信息 NS

ios 获得本地视频的帧数的截图

ios 本地视频文件截图,有的类已经deprecated,提供三个函数以供使用 + (UIImage*)getVideoThumbnailWithUrl:(NSURL*)videoUrl second:(CGFloat)second size:(CGSize)size { if (!videoUrl) { NSLog(@"WARNING:videoUrl为空"); return nil; } AVURLAsset *urlSet = [AVURLAsset assetWithURL:v

iOS使用代码截图

/** * 截图代码 * * @param view 需要截图的view * @param rect 需要截取的区域 * * @return 返回截取的对象 */ + (UIImage *)viewSnapshot:(UIView *)view withInRect:(CGRect)rect { UIGraphicsBeginImageContext(view.bounds.size); [view.layer renderInContext:UIGraphicsGetCurrentContex