Open RaymondBakker opened 7 years ago
There is an API called .layoutSpecBlock
which will allow you to implement this method without creating a subclass, however it is called off the main thread and you can't call a view directly from inside of it.
If the parent of this custom node can determine its size without asking the view, then this can be implemented in the parent -layoutSpecThatFits:
or by setting a .style.*size
on the custom node.
Whatever size is applied to the custom node will get set on the view automatically (they can't be separated, there is nothing special you need to setup). At this point, the internal layoutSubviews or autolayout implementation of the view will take over and it will execute on the main thread.
In conclusion, the only complexity with layout for wrapped views is when you need the size to calculated by the custom view. If you can provide a size to the custom view, then all of the layout inside the view will work normally.
Thank @hannahmbanana, I used a ASRatioSpecLayout, and after a loaded delegate completed, I called setNeedLayout, so I guess the layout still happen on the thread?
I have a custom UIView element that I can't convert to use typical ASDK subclasses and that requires a dynamic height.
From what I gather the best course of action is to wrap the custom view in ASDisplayNode as seen on http://texturegroup.org/docs/display-node.html:
How exactly would one go about defining the size of the node in layoutSpecThatFits in such a way that it will resize the actual view to fit its subviews?