Skip to content

Instantly share code, notes, and snippets.

@michaeldong
Last active November 9, 2018 02:19
Show Gist options
  • Select an option

  • Save michaeldong/29c394e2a8716a1431f870c3e254b885 to your computer and use it in GitHub Desktop.

Select an option

Save michaeldong/29c394e2a8716a1431f870c3e254b885 to your computer and use it in GitHub Desktop.
weex read local image
if([url.scheme isEqualToString:@"file"]) {
NSString *fileName = [NSString stringWithFormat:@"%@@3x", url.host];
NSString *file = [[NSBundle mainBundle] pathForResource:fileName ofType:@"png"];
if(file != nil) {
url = [NSURL fileURLWithPath:file];
}
else {
NSInteger prefixLength = @"file://".length + url.host.length + @"/".length;
if(url.absoluteString.length >= prefixLength) {
NSString *urlString = [url.absoluteString substringFromIndex:prefixLength];
url = [NSURL URLWithString:urlString];
}
else {
NSAssert(true, @"url 非法");
}
}
}
return url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment