swiftasyncdisplaykit

How to add and display new subnode on button tap?


I have ASViewController with root node. In init I add some nodes. I need to display new node after button tap. How I can do it?


Solution

  • Just use 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];
    }