记录一下:
- (void)save
{
//把图片保存到系统相册
//把UIView上面的绘制的内容生成一张图片.保存.
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);
CGContextRef ctx = UIGraphicsGetCurrentContext();
//把画板上的东西绘制到上下文当中
[self.view.layer renderInContext:ctx];
//从上下文当中生成一张图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
//把生成的图片保存到系统相册
//注意:保存图片成功必须得要调用下面方法.
// image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
UIImageWriteToSavedPhotosAlbum(newImage, self, @selector(image:didFinishSavingWithError: contextInfo:), nil);
}
//保存图片成功时调用
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *) contextInfo
{
NSLog(@"保存完成");
}