如何将部分屏幕照片保存到本地iPhone的照片中? [英] How can I save a photo of part of the screen to the local iPhone's Photos?
本文介绍了如何将部分屏幕照片保存到本地iPhone的照片中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将用户选择的UILabel放置在用户也选择的UIImageView上.我想将这两张照片放在一起,有点像屏幕一小部分的屏幕截图.我完全不知道如何执行此操作,也没有任何经验.任何帮助表示赞赏!
I have put a UILabel that the user has chosen over a UIImageView that was also chosen by the user. I would like to put these two into a picture, kind of like a screenshot of a small part of the screen. I have absolutely no idea how to do this and have no experience in this. Any help is appreciated!!
推荐答案
您可以使用要保存的区域的剪贴蒙版设置Bitmap上下文.然后,使用衬里层的renderInContext方法绘制该上下文.
You could setup a Bitmap context with a clipping mask of the area you want to save. Then you use the backing layer's renderInContext method to draw onto that context.
CGSize imageSize = CGSizeMake(960, 580);
UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClipToRect(context, CGRectMake(10,10,200,200); // whatever rect you want
[self.layer renderInContext:context];
UIImage *myImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Save to camera roll
UIImageWriteToSavedPhotosAlbum(myImage, self, @selector(didSaveImage), null);
这篇关于如何将部分屏幕照片保存到本地iPhone的照片中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文