StackGrid

Taking UIStackView one step further

I've been playing around with Swift a lot lately, which included fiddling with iOS 9's new UIStackView. It's a pretty neat way to automatically lay out views in horizontal or vertical direction. This inspired me to try and implement a little concept I've tackled in other languages and environments before.

What I wanted

Basically an automatic and scalable way to distribute views in a space evenly. Which in itself is exactly what UIStackView does, however: a StackView is fixed to one orientation. If you add too many views, they will stretch and the aspect ratio will get really... challenging for UI design.
So what I want is to slice the views in half to maintain a manageable aspect ratio. Like this:


What I made

Well.. pretty much exactly that! It took a lot of fiddeling with the algorithm, if you're interested about the implementation you may read about my approach here.
Here's a little demo of how it works in action:



And to try it out and test it I wrote a little Dashboard-App on top of it, which could look like this:


Try it out!

The entire project is up on GitHub, feel free to clone it, fork it, create issues/pull requests, whatever floats your boat :)

6.10.15