Active Filters: iOS 9

Topics

#16: UIStackView 🚦🚥

Topics

UIStackView changes everything. New in iOS 9, you can think of UIStackView as an abstraction layer on top of Auto Layout. It arranges it's subviews and manages their constraints for you.

One way to think about UIStackView is as the UIKit-born cousin to WKInterfaceGroup, the main layout component for building Apple Watch apps with WatchKit.

UIStackViews layout their arranged subviews horizontally or vertically, and they provide options for how arranged subviews should be aligned and distributed.

You can of course nest many UIStackViews inside each other to easily and quickly create complex layouts. Let's test it out by creating something super common like a UITableViewCell to display a comment. We'll use 2 horizontal and 1 vertical UIStackView:



UIStackView Pro Tips

  • 🌀 Set views to hidden for easy conditional layout
  • 🏃 Hide views in animation blocks to animate the re-layout
  • 🎳 Use size-classes to easily alter layout for different environments
Page 2 of 2