2016-03-16 26 views
0

Table CellAsyncDisplayKit - ASButton尺寸

enter image description here 我学习使用Asyncdisplaykit。我的结果如下图所示。 但我不知道如何约束按钮等于Screen.width/3,它的自动约束条件等于图像宽度。 这是我的代码

let controlStack = ASStackLayoutSpec(direction: ASStackLayoutDirection.Horizontal, spacing: 3.0, justifyContent: ASStackLayoutJustifyContent.Center, alignItems: ASStackLayoutAlignItems.Center, children: [self.mFavoriteButton, self.mCommentButton, self.mShareButton]) 
    controlStack.spacingAfter = 3.0 
    controlStack.spacingBefore = 3.0 

    let insetDateLayout = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 10, left: self.frame.size.width - 100, bottom: 0, right: 0), child: self.mDateTimeNode) 
    let imageLayout = ASStaticLayoutSpec(children: [imagePlace, insetDateLayout]) 


    return ASStackLayoutSpec(direction: .Vertical, spacing: 3.0, justifyContent: ASStackLayoutJustifyContent.Start, alignItems: ASStackLayoutAlignItems.Center, children:[imageLayout, self.mMessageNode, controlStack]) 

回答

2

尝试改变ASStackLayoutAlignItems.CenterASStackLayoutAlignItems.Stretch。并尝试为按钮启用Grow Constraints(需要测试它):

self.mFavoriteButton.flexGrow = true; 
self.mCommentButton.flexGrow = true; 
self.mShareButton.flexGrow = true; 
0

回复,如果你能解决问题!

通常情况下,您希望使用相对大小为0.33的flexBasis做1/3。查看Web/CSS flexbox上的文档以查看flexbasis的示例。