如何在点击按钮时添加和显示新的子节点?

How to add and display new subnode on button tap?

我有带根节点的 ASViewController。在 init 中,我添加了一些节点。我需要在点击按钮后显示新节点。我该怎么做?

只需使用Layout Transition

- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
{


  ASStackLayoutSpec *stack = [[ASStackLayoutSpec alloc] init];
  if (self.buttonState == SignupNodeName) {
    [stack setChildren:@[field, self.buttonNode, self.newNode]];
  } else {
    [stack setChildren:@[field, self.buttonNode]];
  }


  UIEdgeInsets insets = UIEdgeInsetsMake(15.0, 15.0, 15.0, 15.0);
  return [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:stack];
}