0

我正在尝试为元素强制执行最大高度,但我无法准确确定哪个 LayoutSpec 可以帮助我做到这一点。似乎该sizeRange属性是我希望使用的,但它似乎仅适用于ASStaticLayoutSpec,这似乎更像是最后的选择。(我需要约束的这个元素包含ASInsetLayoutSpec在我的案例中。)

这是我的尝试:

        CGSize max = CGSizeMake(constrainedSize.max.width, [self.class maxSinglePhotoHeight]);
        _singlePhotoNode.sizeRange = ASRelativeSizeRangeMake(ASRelativeSizeMakeWithCGSize(constrainedSize.min), ASRelativeSizeMakeWithCGSize(max));
        ASInsetLayoutSpec *inset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:PHOTO_INSET child:_singlePhotoNode];
4

1 回答 1

0

我发现这个:

ASInsetLayoutSpec *insetLayoutSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(INFINITY, INFINITY, INFINITY, INFINITY) child:self.displayNode];

但请确保参数中的最大尺寸不得为 inf,否则您将进入无限布局循环。

于 2016-12-15T10:46:07.913 回答