的截圖一樣,你可以在我的代碼看,我採取截圖並保存到相冊。編程採取特定區域
//for retina displays
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
} else {
UIGraphicsBeginImageContext(self.view.bounds.size);
}
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
起初我用webview.size
代替self.view.bounds.size
和它正常工作,因爲有觀點位於0/0
。但是現在我集中了WebView,但對於給定尺寸,圖片從0/0
開始。
如何配置屏幕截圖在給定大小的另一個location
(例如300/150
)處開始?
或者有另一種方式來採取UIWebView
的照片嗎?
這是否在桌面OSX或只是iphone的工作? – Noitidart 2015-05-07 19:53:32