iPhone - saving current view as image

后端 未结 1 393
栀梦
栀梦 2020-12-12 13:37

How can I save the current view as an image to Camera roll from my application? Is it possible?

Thanks.

相关标签:
1条回答
  • 2020-12-12 14:14

    Found the solution. Might help someone. To save the current view as an image, do the following

    UIGraphicsBeginImageContext(pictureView.bounds.size); 
                
    
    [pictureView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); 
    
    0 讨论(0)
提交回复
热议问题