Convert UIWebview contents to a UIImage

前端 未结 2 728
北荒
北荒 2020-12-04 20:42

I am using a UIWebView to display HTML formatted text. I am not loading a webpage, just supplying a string of HTML to the UIWebView.

Now I want to animate this UIWe

相关标签:
2条回答
  • 2020-12-04 21:04

    I could be wrong but if you set the cache param of CoreAnimation the OS will handle this optimisation for you.

    e.g.

    [UIView setAnimationTransition:transition forView:self.view cache:YES];
    
    0 讨论(0)
  • 2020-12-04 21:06
    UIGraphicsBeginImageContext(webview.bounds.size);
    [webview.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

    You might run into issues if the webview dimensions are large because the webview uses a CATiledLayer that doesn't draw everything for memory reasons.

    The image will include transparency

    0 讨论(0)
提交回复
热议问题