title: load a local css file into a webview
body: <p>I built a simple ios app that loads a html downloaded from a server into a webview.</p>
  
  <pre><code>[self.webView loadHTMLString:notif.html baseURL:nil];
  </code></pre>
  
  <p>This works perfect. The problem is that i nedd to apply a local css file to the webview and I dont know how to do it.</p>
  
  <p>I tried doing it this way, but the styles are not being applied.</p>
  
  <pre><code>NSString *HTML_HEADER=@"&lt;HTML&gt;&lt;HEAD&gt;&lt;link rel='stylesheet' href='style.css' type='text/css'&gt;&lt;/HEAD&gt;&lt;BODY&gt;";
  NSString *HTML_FOOTER=@"&lt;/BODY&gt;&lt;/HTML&gt;";
  NSString *htmlString = [NSString stringWithFormat:@"%@%@%@",HTML_HEADER,notif.html,HTML_FOOTER]; 
  
  NSLog(@"htmlString %@", htmlString);
  [self.webView loadHTMLString:htmlString baseURL:nil];
  </code></pre>
  
  <p>Any idea?</p>
  
  <p>Thanks</p>
  
  <p>UPDATE:</p>
  
  <p>I tried to do the following:</p>
  
  <pre><code>NSString *HTML_HEADER=@"&lt;HTML&gt;&lt;HEAD&gt;&lt;link rel='stylesheet' href='#FILE1#' type='text/css'&gt;&lt;/HEAD&gt;&lt;BODY&gt;";
      NSString *HTML_FOOTER=@"&lt;/BODY&gt;&lt;/HTML&gt;";
  
      NSString *cssFilePath = [[NSBundle mainBundle] pathForResource:@"style" ofType:@"css"];
      NSString *html_header_with_files = [HTML_HEADER stringByReplacingOccurrencesOfString:@"#FILE1#" withString:cssFilePath];
  
  
      NSString *htmlString = [NSString stringWithFormat:@"%@%@%@",html_header_with_files,notif.html,HTML_FOOTER];
  
      NSLog(@"htmlString %@", htmlString);
      [self.webView loadHTMLString:htmlString baseURL:nil];
  </code></pre>
  
  <p>And in Build Phases i have added the style.css</p>
  
  <p><img src="https://i.stack.imgur.com/fr1OM.png" alt="enter image description here"></p>
  
  <p>UPDATE 2:</p>
  
  <p>I also check if the style.css exists with</p>
  
  <pre><code> NSString* filePath = [[NSBundle mainBundle] pathForResource:@"style" ofType:@"css"];
      NSLog(@"\n\nthe string %@",filePath);
  </code></pre>