我无法保存绘制的图像
我有一个 UIView 类型的绘图视图,可以在其中绘制图片。但这种方法只保存了我的白色区域,没有我绘制的图片。为什么?
-(void)saveCurrentScreenToPhotoAlbum
{
UIGraphicsBeginImageContext(drawingView.bounds.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[drawingView.layer renderInContext:ctx];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}
I have a drawingView of type UIView where I can draw pictures. But this method save just I white area without my drawn picture. Why?
-(void)saveCurrentScreenToPhotoAlbum
{
UIGraphicsBeginImageContext(drawingView.bounds.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[drawingView.layer renderInContext:ctx];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
保存图像后,请尝试移至
功能底部。除此之外,它看起来与我使用的代码相同。如果这不起作用,您能否提供更多有关如何/何时调用此方法以及在屏幕上绘制内容的详细信息?
Off the top of my head, try moving
to the bottom of the function, after you save the image. Aside from that it looks the same as the code I used. If that doesn't work, can you provide a few more details on how/when you're calling this method, and what you're drawing to the screen?