2

目前我正在制作“传统”屏幕截图,并使用图形编辑器将它们组合起来以立即显示完整的网页。有没有更有效的方法来制作整个网页的屏幕截图,就像使用Google Chrome的Awesome Screenshot一样?

(不,我没有 iPhone;)

4

2 回答 2

0

请参阅下面的代码。

-(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

}

我从这个链接得到这个代码。希望它会帮助你。

于 2013-12-16T17:32:35.613 回答
0

你必须自己写。

  1. 在您的应用程序中创建全屏webView
  2. 打开你想打开的页面
  3. 操作属性 webView.scrollView 以成功移动到页面底部。
  4. 每次都截屏
  5. 如果您在底部,请将屏幕截图合并到一张大图像中。

我相信这是一种最简单的方法,可以在模拟器上运行。

于 2013-12-16T12:10:27.910 回答