Naveen
Naveen

Reputation: 1251

How can i add a background image for UIWebView?

How can i add a background image for UIWebView as a texture ? I use following code but its not working?

 _webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"light.jpg"]];

Upvotes: 1

Views: 5195

Answers (2)

Naveen
Naveen

Reputation: 1251

Here is the solution

Add this line to viewDidload methode

 [_webView setOpaque:NO];

Add this line to your IBAction methode

_webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"light.jpg"]];

Upvotes: 6

Pratik
Pratik

Reputation: 2399

use below code

[_webView loadHTMLString:string baseURL:nil];
[_webView setOpaque:NO];
_webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"light.jpg"]];

try this you will be succeed

Upvotes: 1

Related Questions