截屏后图片的裁剪

2017-09-07  本文已影响15人  高乔人

//再截屏

UIGraphicsBeginImageContextWithOptions(contentImageView.bounds.size, NO, 0);

CGContextRef ctx1 =  UIGraphicsGetCurrentContext();

[contentView.layer renderInContext:ctx1];

// 这个是要分享图片的样式(自定义的)

UIImage * newImage1 = UIGraphicsGetImageFromCurrentImageContext();

//保存到本地相机

UIImageWriteToSavedPhotosAlbum(newImage1,self,@selector(image:didFinishSavingWithError:contextInfo:),nil);

//裁剪截屏后的图片

//拿到这张图,然后再裁剪吊左边的灰色部分

UIGraphicsBeginImageContext(newImage1.size);

[newImage1 drawInRect:CGRectMake(20,0,newImage1.size.width,newImage1.size.height)];

UIImage *new2Image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageView *img2 = [[UIImageView alloc] init];

[img2 setImage:new2Image];

self.mergeImage = img2.image;

img2.frame = CGRectMake(-30, 0, XHW_W-20  , h);

[contentImageView addSubview:img2];

//拿到这张图,然后再裁剪吊左边的灰色部分

上一篇下一篇

猜你喜欢

热点阅读