一个容器内是否可以有多个纹理节点?
例如,我需要在屏幕的上半部分放置一个 ASTableNode,并在其下方放置一个带有 UIView 块的 ASDisplayNode。
我尝试使用带有 layoutSpecThatFits 的 ASViewController,它返回一个 ASSTackLayoutSpec - 但视图上都没有出现任何子节点。
谢谢!
一个容器内是否可以有多个纹理节点?
例如,我需要在屏幕的上半部分放置一个 ASTableNode,并在其下方放置一个带有 UIView 块的 ASDisplayNode。
我尝试使用带有 layoutSpecThatFits 的 ASViewController,它返回一个 ASSTackLayoutSpec - 但视图上都没有出现任何子节点。
谢谢!
是的,可以将 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
}