将图像从数组保存到本地库

时间:2012-03-14 11:24:43

标签: iphone ipad

将图像从数组保存到本地库时出现问题。

以下代码将图像保存到本地库,但背景为黑色。

  UIGraphicsBeginImageContext(drawImage.frame.size);
    [drawImage.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *saveImage = [UIImage imageWithData:[UndoList objectAtIndex:0]];
    UIImageWriteToSavedPhotosAlbum(saveImage, nil, nil, nil);

当我使用UIGraphicsGetImageFromCurrentImageContext()

 saveImage = UIGraphicsGetImageFromCurrentImageContext();

保存数组中的最后一个索引
@All任何人都可以帮我解决问题。

提前致谢

1 个答案:

答案 0 :(得分:0)

不是黑色背景,但它是alpha 0背景...因为你保存PNG图像...以及为什么你渲染图层,如果你可以保存drawImage.image? 使用 UIImageJPEGRepresentation保存数据图像 UIImagePNGRepresentation

相关问题