Reputation: 25969
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 UIWebView on screen, actually several of them (2-10 at a time). UIWebView is a little heavy, and although I haven't attempted it yet, I am planning for the worst. (I don't think this is premature optimization, I 'm almost positive this will be an issue)
To get around the problem, I figured I could convert the contents of the UIWebViews to UIImages and animate them instead.
So, my questions are:
Thanks for any suggestions
Upvotes: 10
Views: 8511
Reputation:
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];
Upvotes: 0
Reputation: 45581
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
Upvotes: 21