Javascript uiwebview部分的图像

Javascript uiwebview部分的图像,javascript,image,uiwebview,touch,Javascript,Image,Uiwebview,Touch,我有一个问题,我得到一个uiwebview的截图,代码如下: UIGraphicsBeginImageContextWithOptions(self.myWebView.bounds.size, self.myWebView.opaque, 0.0); [self.myWebView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * img = UIGraphicsGetImageFromCurrentImageCon

我有一个问题,我得到一个uiwebview的截图,代码如下:

UIGraphicsBeginImageContextWithOptions(self.myWebView.bounds.size, self.myWebView.opaque, 0.0);
[self.myWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

所有工作都很完美,现在我需要拍摄一个特定div的屏幕截图,用户在uiwebview中长按,然后我检测到被触摸的div,并为这个特定div拍摄一张照片。最好的方法是什么?

您似乎需要执行RenderContext

 // Size of the result rendered image
CGSize targetImageSize = CGSizeMake(100, 100);
// Check for retina image rendering option
if (NULL != UIGraphicsBeginImageContextWithOptions) UIGraphicsBeginImageContextWithOptions(targetImageSize, NO, 0);
else UIGraphicsBeginImageContext(targetImageSize);

CGContextRef context = UIGraphicsGetCurrentContext();
// The view to be rendered
[[yourImageView layer] renderInContext:context];
// Get the rendered image
UIImage *original_image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
至于其他部分,据我所知,没有公共方法允许您拍摄整个屏幕的截图(即使用状态栏)。有一个UIGetScreenImage允许您使用它来实现此功能。但是,由于它是一种私有方法,如果您将应用提交到应用商店,您的应用将被拒绝

这等于我的代码:)这是一种改变图层位置的方法吗?不仅仅是尺寸?