屏幕截图(UIView转为图像存储到本地)
在做课设的时候,涉及到了一个功能,类似屏幕截图一样,把当前视图裁剪下来,当做图片寸到本地相册。
实现起来很简单,几行代码的事。
下面直接上代码了。
1.在头文件导入库。
#import <QuartzCore/QuartzCore.h>
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layerrenderInContext:UIGraphicsGetCurrentContext()];
UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image,self,nil, nil);
学习的路上,与君共勉。
本文介绍了一个简单的功能实现:将当前UIView转换为图像并保存到本地相册。通过几行Objective-C代码即可完成,适用于iOS应用开发。
1249

被折叠的 条评论
为什么被折叠?



