NSString *myHtml = [NSString stringWithFormat:
@"<html><head>"
"<style type=\"text/css\">"
"body{"
"background-image:url(%@);"
"}"
",</style>"
"</head>"
"<body>Hello world</body></html>", imgName];
// baseURL for background image, otherwise nil
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[self.myWebView loadHTMLString:myHtml baseURL:baseURL];
Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts
Monday, May 10, 2010
UIWebView with Custom Background Image
Taking UIWebView into use is pretty easy, customizing is a bit more complicated. Here's how you can define your own image as background.
Thursday, February 25, 2010
How to Disable UIWebView Selection
You could do this by running a short javaScript line at webViewDidFinishLoad, but I find this more elegant: define UIWebView properties in CSS.
As a bonus I left there also how to disable link selection popup.NSString *myHtml = [NSString stringWithFormat: @"<html><head>" "<style type=\"text/css\">" // Disable Open/Copy/Cancel alert with long link selection "* {" "-webkit-touch-callout: none;" // Disable selection/Copy of UIWebView "-webkit-user-select: none;" "}" ",</style>" "</head><body>%@</body></html>", message.body]; [myWebView loadHTMLString:myHtml baseURL:nil];
Labels:
CSS,
iphone,
javaScript,
NSString,
UIWebView
Subscribe to:
Posts (Atom)