2
目前,我正在製作「傳統」屏幕截圖,並使用圖形編輯器將它們組合在一起,以便一次顯示完整的網頁。是否有更高效的方式製作完整網頁的屏幕截圖,就像Google Chrome使用Awesome Screenshot一樣?是否可以在iOS模擬器中捕捉整個網頁的屏幕截圖?
(不,我沒有一個iPhone)
目前,我正在製作「傳統」屏幕截圖,並使用圖形編輯器將它們組合在一起,以便一次顯示完整的網頁。是否有更高效的方式製作完整網頁的屏幕截圖,就像Google Chrome使用Awesome Screenshot一樣?是否可以在iOS模擬器中捕捉整個網頁的屏幕截圖?
(不,我沒有一個iPhone)
你必須把它寫在你自己的。
webView
。我相信這是一個最簡單的方法,並在模擬器上運行。
請參閱下面的代碼。
-(NSData *)getImageFromView:(UIView *)view // Mine is UIWebView but should work for any
{
NSData *pngImg;
CGFloat max, scale = 1.0;
CGSize viewSize = [view bounds].size;
// Get the size of the the FULL Content, not just the bit that is visible
CGSize size = [view sizeThatFits:CGSizeZero];
// Scale down if on iPad to something more reasonable
max = (viewSize.width > viewSize.height) ? viewSize.width : viewSize.height;
if(max > 960)
scale = 960/max;
UIGraphicsBeginImageContextWithOptions(size, YES, scale);
// Set the view to the FULL size of the content.
[view setFrame: CGRectMake(0, 0, size.width, size.height)];
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
pngImg = UIImagePNGRepresentation(UIGraphicsGetImageFromCurrentImageContext());
UIGraphicsEndImageContext();
return pngImg; // Voila an image of the ENTIRE CONTENT, not just visible bit
}
我從this鏈接得到這個代碼。希望它能幫助你。
我沒有開發移動應用程序的經驗,我只想測試一個網站而不是移動應用程序。但是,如果您的解決方案有效,則可以爲此目的開發應用程序。 –