diff --git a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m index 970596b8..841103b5 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m @@ -21,17 +21,14 @@ // #import "DoricImageNode.h" -#import "Doric.h" #import "YYWebImage.h" +#import "DoricExtensions.h" +#import "DoricUtil.h" @interface DoricImageView : YYAnimatedImageView @end @implementation DoricImageView - -- (CGSize)sizeThatFits:(CGSize)size { - return [self sizeThatFits:size]; -} @end @interface DoricImageNode () diff --git a/doric-iOS/Pod/Classes/Shader/DoricLayouts.m b/doric-iOS/Pod/Classes/Shader/DoricLayouts.m index 515988f9..10d7cee3 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricLayouts.m +++ b/doric-iOS/Pod/Classes/Shader/DoricLayouts.m @@ -169,10 +169,23 @@ - (void)setFrame { - (void)measureUndefinedContent:(CGSize)targetSize { CGSize measuredSize = [self.view sizeThatFits:targetSize]; if (self.widthSpec == DoricLayoutFit) { - self.measuredWidth = measuredSize.width + self.paddingLeft + self.paddingRight; + if ([self.view isKindOfClass:[UIImageView class]] + && self.heightSpec != DoricLayoutFit && measuredSize.height > 0) { + self.measuredWidth = measuredSize.width / measuredSize.height * self.measuredHeight + + self.paddingLeft + self.paddingRight; + } else { + self.measuredWidth = measuredSize.width + self.paddingLeft + self.paddingRight; + } } if (self.heightSpec == DoricLayoutFit) { - self.measuredHeight = measuredSize.height + self.paddingTop + self.paddingBottom; + if ([self.view isKindOfClass:[UIImageView class]] + && self.widthSpec != DoricLayoutFit && measuredSize.width > 0) { + self.measuredHeight = measuredSize.height / measuredSize.width * self.measuredWidth + + self.paddingTop + self.paddingBottom; + } else { + self.measuredHeight = measuredSize.height + self.paddingTop + self.paddingBottom; + } + } }