Can anyone help me with add html file in webview? I want to present html data with my options of text size, font and image size.
I have this html code, it works when I add it in local file :
max-width: 348px !important;
font-size: 15px !important;
font-size: HelveticaNeue !important;
I think if you want to add these html code at the end of a file, it's no problem. But as I know, the style needs to add in head, so I think you must Analysis the html string and find where to insert the style. The the problem is seem to be a string stitching.
let path = dir.stringByAppendingPathComponent(file); //reading let text = String(contentsOfFile: path, encoding: NSUTF8StringEncoding, error: nil) // Here you should insert the <style> string in text // Or you just add the <style> at the end of the text //writing text.writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding, error: nil)