开发者

I can't save a drawn image

开发者 https://www.devze.com 2023-04-01 09:18 出处:网络
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?

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 = UIGraphicsGetImage开发者_开发技巧FromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}


Off the top of my head, try moving

UIGraphicsEndImageContext();

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号