iOS: fix when flexlayout's width is most,it cannot wrap child view properly
This commit is contained in:
parent
13ba43cb19
commit
037f5afbe0
@ -47,7 +47,22 @@ - (CGSize)sizeThatFits:(CGSize)size {
|
||||
if (self.yoga.isLeaf) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
return [self.yoga intrinsicSize];
|
||||
YGValue maxWidth = self.yoga.maxWidth;
|
||||
YGValue maxHeight = self.yoga.maxHeight;
|
||||
if (maxWidth.unit == YGUnitPoint) {
|
||||
self.yoga.maxWidth = YGPointValue(MIN(maxWidth.value, size.width));
|
||||
} else {
|
||||
self.yoga.maxWidth = YGPointValue(size.width);
|
||||
}
|
||||
if (maxHeight.unit == YGUnitPoint) {
|
||||
self.yoga.maxHeight = YGPointValue(MIN(maxHeight.value, size.height));
|
||||
} else {
|
||||
self.yoga.maxHeight = YGPointValue(size.height);
|
||||
}
|
||||
CGSize ret = [self.yoga intrinsicSize];
|
||||
self.yoga.maxWidth = maxWidth;
|
||||
self.yoga.maxHeight = maxHeight;
|
||||
return ret;
|
||||
}
|
||||
@end
|
||||
|
||||
|
Reference in New Issue
Block a user