Home Tutorial Iphone Examples UIWebView Background Color

 
 

UIWebView Background Color
Posted on: August 9, 2010 at 12:00 AM
If you wanted to change the background color on UIWebView in iPhone SDK, then you required to set the background color of UIWebView using UIColor.

UIWebView Background Color

If you wanted to change the background color on UIWebView in iPhone SDK, then you required to set the background color of UIWebView using UIColor. UIColor object represents color and opacity (alpha value). Where as setBackgroundColor will allow you to change the color of background area of UIWebView or UIView.

This example illustrate you how to change the color of UIWebView in iPhone SDK based application. To change the color of background first we need to set the backgroundcolor as clearColor and then set the required color to it as given in the following code.

- (void)viewDidLoad {
[super viewDidLoad];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]]];

//Set the UIWebView background color and opaque:NO
[webView setBackgroundColor:[UIColor clearColor]];
[webView setBackgroundColor:[UIColor purpleColor]];

[webView setOpaque:NO];

}

On running the application you'll find the output similar to give image.

Download Code

Related Tags for UIWebView Background Color:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.