Generally, UIWebView class is used to embed the web content into your application including background color of that page too.
Generally, UIWebView class is used to embed the web content into your application including background color of that page too.Generally, UIWebView class is used to embed the web content into your application including background color of that page too. But in case if you wanted to load the page in transparent color.. you required to set the background color as clear color.
Syntax to get Transparent UIWebView: To get a transparent background for a UIWebView in iphone just find the given solution..
- First of all set your background color of the UIWebView to clear
- and if in HTML set the css for the body to background-color: transparent
Code snippet (UIWebView)
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
Code snippet (HTML)
body {
margin: 0;
padding: 0;
width: 220px;
background-color: transparent;
}
But if you are directly loading the URL from web just copy the given code into your implementation file.
- (void)viewDidLoad {
[super viewDidLoad];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.roseindia.net/"]]];
//Set the UIWebView background color clear and opaque:NO
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
}
Basically using UIColor, you can set any color for you background from the given UIcolor set ...
- blackColor
- darkGrayColor
- lightGrayColor
- whiteColor
- grayColor
- redColor
- greenColor
- blueColor
- cyanColor
- yellowColor
- magentaColor
- orangeColor
- purpleColor
- brownColor
- clearColor
or you can set your own color through ....
+ (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
Download Code