background image in html page in iphone
I m the beginner in iphone development.
How i call the background image from my project dir开发者_如何转开发ectory in Xcode in html page. I have taken previously UISegment control and after that i calling two html page on webview in uisegmentcontroller. Now i want to set background images on those html pages. It is possible? if it is yes then how?
thanks in advance..
You can specify a base URL when loading HTML in a UIWebView. If you set the base URL to your bundle path, you can simply reference the background image as if it was in the current directory.
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[webView loadHTMLString:htmlPage baseURL:baseURL];
in your HTML:
body {
background: url(bg.jpg); // "bg.jpg" is in your bundle
}
精彩评论