-
-
Save michaeldong/29c394e2a8716a1431f870c3e254b885 to your computer and use it in GitHub Desktop.
weex read local image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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