2016-03-16 48 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的示例。