Joel
Joel

Reputation: 308

ASyncDisplayKit (Texture) - Resizing a visible node

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!

Upvotes: 0

Views: 788

Answers (1)

apptimal
apptimal

Reputation: 494

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.

Upvotes: 2

Related Questions