iOS 始终为图像添加白色背景

iOS always add white background to images

我正在编写一个应用进程映像。但是当我将图像的 alpha 更改为 0 时,这意味着该图像将是透明的。然后我将这张图片保存到照片库。

 UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

但是当我再次打开这张图片时,我发现它的背景是白色的。 有人知道为什么吗?

你保存为jpeg了吗?

试试这个:

NSData* pngdata = UIImagePNGRepresentation (image); 
UIImage* img = [UIImage imageWithData:pngdata];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);