【发布时间】:2015-10-18 20:49:39
【问题描述】:
当用户点击并按住图片时,我希望能够将图片从UIWebView 保存到照片应用中。
当我在 Objective-c 中编程时,我已经设法从 UIWebView 中保存了一张图像,但是现在我正在快速学习 swift,它似乎有点不同。
这就是我在 Objective-C 中的做法:
-(IBAction)saveWeb:(id)sender
{
UIGraphicsBeginImageContext(webview.frame.size);
[self.webview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil,nil,nil);
}
【问题讨论】: