LGStackView is a control that is a simplified version of UIStackView supporting iOS8. It is used to stack dynamic subviews constrained with autolayout constraints in Interface Builder based on their hidden or alpha property. Once the constraints are set up for all views, there are two IBInspectable properties in Interface Builder to set up. First is the orientation (vertical/horizontal), and the seconds is padding among views. The order of the views is determined by their z index, which is set by reordering subviews list in Interface Builder.
Once the hidden or alpha property is changed, invalidateLayout method should be called to arrange constraints. Only horizontal/vertical constraints between views are modified. Constraints change can be animated:
self.someSubview.alpha = 0
The code is available on GitHub: https://github.com/lukagabric/LGStackView
If you liked this blog post I’d appreciate if you followed me on Twitter