iPhone - 将当前视图保存为图像

los*_*sit 24 iphone

如何将当前视图作为图像保存到我的应用程序的相机胶卷?可能吗?

谢谢.

los*_*sit 44

找到了解决方案.可以帮助别人.要将当前视图另存为图像,请执行以下操作

UIGraphicsBeginImageContext(pictureView.bounds.size); ?                

[pictureView.layer renderInContext:UIGraphicsGetCurrentContext()]; 

UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); 
Run Code Online (Sandbox Code Playgroud)

  • 添加#import <QuartzCore/QuartzCore.h>以使用此代码. (10认同)