控制ASdisplayNode高度与单元格高度一致

时间:2017-08-17 01:09:47

标签: asyncdisplaykit

如何使控件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;
}

enter image description here

1 个答案:

答案 0 :(得分: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;
}