0

如何让控件 ASdisplayNode 与单元格高度一致?

-  (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize{
NSMutableArray *rightArray =[[NSMutableArray alloc]initWithObjects:_titleNode, _descNode,nil];
[rightArray addObjectsFromArray:_replayNodes];
ASStackLayoutSpec *verStackLayout = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:8 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:rightArray];
verStackLayout.style.flexGrow = YES;
verStackLayout.style.flexShrink  = YES;
self.dateNode.style.preferredSize =  CGSizeMake(130 ,50);//How high is the height of cell?
self.dateNode.style.flexShrink = YES;
 ASStackLayoutSpec *horStackLayout = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:10 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[self.dateNode,verStackLayout]];
horStackLayout.style.flexShrink = YES;
return horStackLayout;
}

在此处输入图像描述

4

1 回答 1

0

试试这段代码,告诉你得到了什么?

-  (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize{
NSMutableArray *rightArray =[[NSMutableArray alloc]initWithObjects:_titleNode, _descNode,nil];
[rightArray addObjectsFromArray:_replayNodes];
ASStackLayoutSpec *verStackLayout = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:8 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:rightArray];
verStackLayout.style.flexGrow = YES;
verStackLayout.style.flexShrink  = YES;
self.dateNode.style.flexShrink = YES;
ASStackLayoutSpec *horStackLayout = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal spacing:10 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStretch children:@[self.dateNode,verStackLayout]];
horStackLayout.style.flexShrink = YES;
horStackLayout.style.flexGrow = YES;
horStackLayout.style.alignSelf = ASStackLayoutAlignItemsStretch;
return horStackLayout;
}
于 2017-08-19T09:05:45.823 回答