LinkedInAttic / LayoutKit

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
http://layoutkit.org
Apache License 2.0
3.16k stars 267 forks source link

How to change SizeLayout's width/height dynamically? #99

Closed YoonjaeYoo closed 7 years ago

YoonjaeYoo commented 7 years ago

Is it possible to change SizeLayout's width/height or show/hide a Layout after view has been made? Thank you.

nicksnyder commented 7 years ago

There are two general approaches.

(1) Grab a reference to the view in the config block for the layout. Then you can do whatever you want with that view later. If you resize the view though, it won't affect any of the other views in the layout so this usually isn't what you want unless the change is ephemeral and/or you don't want the rest of the layout to update.

(2) Initialize a new Layout and apply that layout to the view hierarchy. If you use viewReuseId it will efficiently reuse views. You can also animate the transition if you want: http://layoutkit.org/animations/. Basically the whole point of LayoutKit is to make the Layout -> View process fast and efficient so if you want the screen to look different, then create a new Layout for the new state and then apply it.

Feel free to re-open if you have further questions.

YoonjaeYoo commented 7 years ago

Thank you @nicksnyder