2

一个容器内是否可以有多个纹理节点?

例如,我需要在屏幕的上半部分放置一个 ASTableNode,并在其下方放置一个带有 UIView 块的 ASDisplayNode。

我尝试使用带有 layoutSpecThatFits 的 ASViewController,它返回一个 ASSTackLayoutSpec - 但视图上都没有出现任何子节点。

谢谢!

4

1 回答 1

1

是的,可以将 ASTableNode 和 ASDisplayNode 放在同一个堆栈中。使用水平堆栈布局,将节点flexGrow属性设置为相等的值(因此它们同样增长)并在您的节点上设置automaticallyManagesSubnodes为。true

override init() {
    ///Initialize nodes if not initialized on declaration
    super.init()
    automaticallyManagesSubnodes = true
}

override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec {
    let stack = ASStackLayoutSpec.vertical()
    stack.children = [tableNode, displayNode]
    tableNode.style.flexGrow = 1
    displayNode.style.flexGrow = 1

    ///For testing
    displayNode.backgroundColor = .red
    tableNode.backgroundColor = .blue
}
于 2018-01-05T21:44:24.247 回答