Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created April 15, 2012 14:47
Show Gist options
  • Save minhnc/2393239 to your computer and use it in GitHub Desktop.
Save minhnc/2393239 to your computer and use it in GitHub Desktop.
ImageView with SVG
var win = Titanium.UI.createWindow({backgroundColor: 'white'});
var img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
var index = img.indexOf('base64,');
img = img.substring(index + 'base64,'.length);
Ti.API.info(img);
var imageView = Ti.UI.createImageView({
image: Ti.Utils.base64decode(img),
width: 100,
height: 100
});
win.add(imageView);
win.open();
@bitsofparag
Copy link

I used this to render an SVG image in a tableview. I get the following error:

The application has crashed with an uncaught exception 'NSInvalidArgumentException'
[ERROR] invalid image type. expected TiBlob, String, TiFile, was: TiBlob -TiUIImageView setImage_:

This is in Titanium 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment