English 中文(简体)
• 如何将背景形象定在超文本中
原标题:How to set Background Image in HTML page in iphone

Thanks in advance for sending answer to me........ Im the beginner in iphone development.

I tried last 2 days to set background image in UIWebView in iphone.But i can t. Becoze i doesn t know how to take(proper path) of the image from of project directory and proper syntax of that.

最佳回答

利用该法典将html装上背景图像。

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"bgfull.png"];
        NSURL *url = [[NSURL alloc] initFileURLWithPath:path isDirectory:NO];

        NSString *size = [@"100%25" stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];





        NSString *contentHtml = [NSString stringWithFormat:@"<html>
                                 <head>
                                 <style type="text/css">
                                 html {height:%@;}
                                 body {height:%@; margin:0; padding:0; color:white; font-size:40px;}
                                 #bg {position:fixed; top:0; left:0; width:%@; height:%@;}
                                 #content {position:relative; z-index:1;}
                                 </style>
                                 </head>
                                 <body>
                                 <div id="bg"><img src="%@" width="%@" height="%@"></div>
                                 <div id="content"><font color="#DAF899" size="+4"><b>%@</b></font><p>%@</p></div>
                                 </body>
                                 </html>", size, size, size, size, url, size, size, self.navigationItem.title, content];






        [webView loadHTMLString:contentHtml baseURL:nil];

希望这一帮助。

问题回答
  1. Create a UIImageView and load your image.
  2. Create a UIWebView and set the background color to [UIColor clearColor].
  3. Add the UIWebView as a subview to the UIImageView.

IDWebView显示超文本,以显示网络形象,你需要向以下网站提供适当的超文本内容:load/2006/2String:baseURL:loadData:MIMEType:textEncodingName:URL:





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签