---
title: "Converting web view contents into UIImage in iOS."  
description: "Converting web view contents into UIImage in iOS."  
author: "Anurag Sharma"  
published: 2016-01-06  
updated: 2016-01-07  
canonical: https://www.mindstick.com/forum/33838/converting-web-view-contents-into-uiimage-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Converting web view contents into UIImage in iOS.

I have created a **UIWebView** in our [iPhone application](https://www.mindstick.com/forum/23139/can-i-embed-a-custom-font-in-an-iphone-application) for displaying HTML [formatted text](https://answers.mindstick.com/qa/95106/what-is-the-best-way-to-convert-a-pdf-to-nicely-formatted-text). I want to animate web view on screen actually (2 to 10 times). and also my web views having [transparent](https://www.mindstick.com/forum/1784/wpf-webbrowser-on-transparent-window) backgrounds.\
after that web view is little heavy and although I haven't attempt it yet. I'm [planning](https://answers.mindstick.com/qa/32060/who-is-the-chairman-of-planning-commissison) for the worst(I don't think it is premature [optimization](https://yourviews.mindstick.com/view/85459/what-is-conversion-rate-optimization-and-how-to-get-started), I think it can be an issue).\
\
I want to [convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) those contents of the web view into UIImages and using [animation](https://www.mindstick.com/articles/13040/seven-helpful-tips-to-start-and-grow-an-animation-video-company) on it.\
So, my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is: How can I convert Web View contents into UIImage or CGImageRef? and Is [transparency](https://www.mindstick.com/articles/336962/how-blockchain-technology-be-applied-to-improve-transparency-in-industries) of web view be carried on to the UIImage?\
Anyone have suggestions for my Issue, then please help me.

## Replies

### Reply by Tarun Kumar

Yes, you can create UIWebView into Images. below I am providing a solution:\

```
UIGraphicsBeginImageContext (webViewController.bounds.size) ;[webViewController.layer renderInContext:UIGraphicsGetCurrentContext()];UIImage *image = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();
```

the above code will generate issue if your web views dimensions are bigger because the webview uses a CATiledLayer that doesn't draw everything, for memory reasons, and the transparent image can also include.


---

Original Source: https://www.mindstick.com/forum/33838/converting-web-view-contents-into-uiimage-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
