Add support for web-style data-uris

Summary:
This implements base64-encoded data-uris for the Image component.
Closes https://github.com/facebook/react-native/pull/576
Github Author: Colin Ramsay <colinramsay@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
Colin Ramsay 2015-04-01 10:50:00 -07:00
parent 3de7ad6c33
commit 4838d5921f
1 changed files with 5 additions and 1 deletions

View File

@ -547,7 +547,11 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
UIImage *image = nil;
NSString *path = json;
if ([path isAbsolutePath]) {
if ([path hasPrefix:@"data:"]) {
NSURL *url = [NSURL URLWithString:path];
NSData *imageData = [NSData dataWithContentsOfURL:url];
image = [UIImage imageWithData:imageData];
} else if ([path isAbsolutePath]) {
image = [UIImage imageWithContentsOfFile:path];
} else {
image = [UIImage imageNamed:path];