Xcode 9 has taken another step forward with vectors inside of iOS projects. It will apparently retain the source PDF so that images may be generated as needed with full quality.
I'm wondering if it's yet possible to access these images from the HTML inside of a UIWebView?
I can imagine three possible ways of doing this:
Some magic that you place within your HTML or CSS that iOS will recognize and replace. For example:
<img src={{Asset Name}}>
Knowing the naming scheme to get at the asset. For example:
<img src="some/path/asset~ipad@3x">
"Render" the image outside the UIWebView and pass it in.
Are any of these possible? Is there another way?
Given how far we've come with vectors, I'd hate to have to pre-render every image variation and package them outside the asset catalog if I don't have to.
Today i needed to render the
UIImage
from XCAsset's into anUIWebView
.My requirement was to prepare the appropriate
HTML
and load it into theUIWebView
as followsIn order to load images from XCAsset's, first loaded the image into an
UIImage
, then convert it back toBase64 Encoding
, then put the image into the<img>
tag.The code looks like following
For Convenience i moved the
UIImage
->Base64 String
conversion into an extension.