Skip to main content
deleted 1 character in body
Source Link
    "<img<img src = @"yourimage.png">
    "<img src = @"yourimage.png">
    <img src = @"yourimage.png">
Source Link

You can set your image like this.

    "<img src = @"yourimage.png">

Steps:

1. Set your image file path in image src tag in correct manner
2. Then set the width and height of the image
3. Accessing your image file path and configure in your project.

Suppose you want to load the image inside the body to a web view content. you can go with the following code::

Step 1:

    NSString *localPath = [[NSBundle mainBundle]    
    pathForResource:@"demo.html" ofType:nil];
        NSString *html = [NSString  stringWithContentsOfFile: localPath encoding:NSUTF8StringEncoding error:NULL];    
NSString *path = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];
    [mywebview  loadHTMLString:html baseURL:baseURL];

Step 2: demo.html contains the following one.

NSString *htmlString = [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];
[mywebview loadHTMLString:htmlString baseURL:nil]

Screenshots have given below in attachment.

enter image description here Try out this. surely will help you.