iOS: fix image's stretch mode error when async load image data.

This commit is contained in:
吴尚昆 2022-03-17 17:30:25 +08:00 committed by osborn
parent 3f017a9beb
commit 3d4326ba7b

View File

@ -86,6 +86,8 @@ @interface DoricImageNode ()
@property(nonatomic, strong) NSDictionary *stretchInsetDic;
@property(nonatomic, strong) NSDictionary *tileInsetDic;
@property(nonatomic, assign) CGFloat imageScale;
@property(nonatomic, strong) NSDictionary *props;
@end
@implementation DoricImageNode
@ -123,6 +125,7 @@ - (void)blend:(NSDictionary *)props {
[props[@"loadCallback"] also:^(NSString *it) {
self.loadCallbackId = it;
}];
self.props = props;
[super blend:props];
}
@ -281,6 +284,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
[self callJSResponse:self.loadCallbackId, nil];
}
}
[self afterBlended:self.props];
}];
}];
[asyncResult setExceptionCallback:^(NSException *e) {
@ -331,6 +335,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
if (async && self.needReload) {
[self.superNode subNodeContentChanged:self];
}
[self afterBlended:self.props];
}
}];
});
@ -370,7 +375,8 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
[self.superNode subNodeContentChanged:self];
}
}
}];
[self afterBlended:self.props];
}];
#else
DoricLog(@"Do not support load image url");
#endif
@ -663,6 +669,9 @@ - (UIImage *)imageFromData:(NSData *)imgData {
}
- (void)afterBlended:(NSDictionary *)props {
if (CGSizeEqualToSize(self.view.image.size, CGSizeZero)) {
return;
}
if (self.stretchInsetDic != nil) {
CGFloat left = [self.stretchInsetDic[@"left"] floatValue];
CGFloat top = [self.stretchInsetDic[@"top"] floatValue];
@ -682,7 +691,6 @@ - (void)afterBlended:(NSDictionary *)props {
}
}
- (NSNumber *)isAnimating {
if (self.view.animating) {
return @(YES);