2

Is it possible to have multiple Texture nodes inside one container?

For example, I need to have an ASTableNode on the top half of a screen, and an ASDisplayNode with a UIView block underneath that.

I have tried using an ASViewController with a layoutSpecThatFits which returns an ASSTackLayoutSpec - but neither of the subnodes appear on the view.

Thank you!

Joel
  • 199
  • 2
  • 10

1 Answers1

1

Yes, it is possible to place both the ASTableNode and ASDisplayNode in the same stack. Use a horizontal stack layout, set the nodes flexGrow property to equal values (so they grow equally) and set automaticallyManagesSubnodes to true on your node.

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
}
Dog
  • 474
  • 8
  • 25