feat:add imagepath and imageRes for Image

This commit is contained in:
pengfei.zhou
2020-03-12 19:56:47 +08:00
committed by osborn
parent 7b371ca58b
commit a6df529f8f
9 changed files with 172 additions and 58 deletions

View File

@@ -181,6 +181,33 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
}
}
} else if ([@"imageRes" isEqualToString:name]) {
UIImage *image = [UIImage imageNamed:prop];
view.image = image;
if (self.loadCallbackId.length > 0) {
if (image) {
[self callJSResponse:self.loadCallbackId,
@{@"width": @(image.size.width), @"height": @(image.size.height)},
nil];
} else {
[self callJSResponse:self.loadCallbackId, nil];
}
}
} else if ([@"imagePath" isEqualToString:name]) {
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *fullPath = [path stringByAppendingPathComponent:prop];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
view.image = image;
if (self.loadCallbackId.length > 0) {
if (image) {
[self callJSResponse:self.loadCallbackId,
@{@"width": @(image.size.width), @"height": @(image.size.height)},
nil];
} else {
[self callJSResponse:self.loadCallbackId, nil];
}
}
} else {
[super blendView:view forPropName:name propValue:prop];
}