0

I have an ASStackLayoutSpec as the container for numerous other nodes. One of those subnodes is an ASTextNode with a maximumNumberOfLines set to 4. If a user clicks a "Read More" button underneath, I want to be able to remove the max lines and resize the ASTextNode so that everything displays.

Can anybody point me in the right direction?

Thank you!

Joel
  • 199
  • 2
  • 10

1 Answers1

2

You can try changing the number of lines to 0 and then call setNeedsLayout() and layoutIfNeeded() on the node.

It could look like this:

func buttonPressed(sender: UIButton) {
    textNode.numberOfLines = 0
    textNode.setNeedsLayout()
    textNode.layoutIfNeeded()
}

The setNeedsLayout() may not even be needed, you can try without it and see where it goes.

Dog
  • 474
  • 8
  • 25
  • This did it - and in Texture, the setNeedsLayout() IS necessary. Thank you so much! – Joel Dec 31 '17 at 14:33