是否可以在一个容器内有多个纹理节点?
例如,我需要在屏幕的上半部分有一个 ASTableNode,在其下方有一个带有 UIView block 的 ASDisplayNode。
我尝试过使用 ASViewController 和 layoutSpecThatFits 返回 ASSTackLayoutSpec - 但两个子节点都没有出现在 View 上。
谢谢!
最佳答案
是的,可以将 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
}
关于ios - ASyncDisplayKit - 一个容器中的多个节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48121436/