我想从一些uiwebview内容的部分创建uiimage.
假设我的webview的大小为(200,200).它的contentview内容为(800,200),可滚动,
我想截取以下rect CGRectMake(400,200,200)的屏幕截图.
我试过这个:
CGRect rect = CGRectMake(pageIndex * webView.frame.size.width,webView.frame.size.width,webView.frame.size.height); UIGraphicsBeginImageContext([webView getScrollView].bounds.size); CGContextRef c = UIGraphicsGetCurrentContext(); CGContextClipToRect(c,rect); [webView.layer renderInContext:c]; UIGraphicsEndImageContext();
它适用于webview的第一页,但对于其他页面,它不会拍摄图像,而是创建了白色图像.
可能是什么问题呢?如何创建scrollview当前不可见部分的屏幕截图?
感谢帮助,