iOS:avoid requestLayout before blend finished

This commit is contained in:
pengfei.zhou 2020-04-09 11:21:41 +08:00 committed by osborn
parent c7f3f74b69
commit 410c01ba1c

View File

@ -112,6 +112,7 @@ - (UIImage *)currentErrorImage {
- (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop { - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"imageUrl" isEqualToString:name]) { if ([@"imageUrl" isEqualToString:name]) {
__weak typeof(self) _self = self; __weak typeof(self) _self = self;
BOOL async = NO;
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) { [view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
__strong typeof(_self) self = _self; __strong typeof(_self) self = _self;
if (self.placeHolderColor || self.errorColor) { if (self.placeHolderColor || self.errorColor) {
@ -134,9 +135,12 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
while (node.superNode != nil) { while (node.superNode != nil) {
node = node.superNode; node = node.superNode;
} }
if (async) {
[node requestLayout]; [node requestLayout];
} }
}
}]; }];
async = YES;
} else if ([@"scaleType" isEqualToString:name]) { } else if ([@"scaleType" isEqualToString:name]) {
switch ([prop integerValue]) { switch ([prop integerValue]) {
case 1: { case 1: {