StackView

open class StackView: UIView

A view that stacks its subviews along a single axis.

It is similar to UIStackView except that it uses StackLayout instead of Auto Layout, which means layout is much faster.

Although StackView is faster than UIStackView, it still does layout on the main thread. If you want to get the full benefit of LayoutKit, use StackLayout directly.

Unlike UIStackView, if you position StackView with Auto Layout, you must call invalidateIntrinsicContentSize on that StackView whenever any of its subviews’ intrinsic content sizes change (e.g. changing the text of a UILabel that is positioned by the StackView). Otherwise, Auto Layout won’t recompute the layout of the StackView.

Subviews MUST implement sizeThatFits so StackView can allocate space correctly. If a subview uses Auto Layout, then the subview may implement sizeThatFits by calling systemLayoutSizeFittingSize.

  • The axis along which arranged views are stacked.

    Declaration

    Swift

    open let axis: Axis
  • The distance in points between adjacent edges of sublayouts along the axis. For Distribution.EqualSpacing, this is a minimum spacing. For all other distributions it is an exact spacing.

    Declaration

    Swift

    open let spacing: CGFloat
  • The distribution of space along the stack’s axis.

    Declaration

    Swift

    open let distribution: StackLayoutDistribution
  • The distance that the arranged views are inset from the stack view. Defaults to 0.

    Declaration

    Swift

    open let contentInsets: UIEdgeInsets
  • The stack’s alignment inside its parent.

    Declaration

    Swift

    open let alignment: Alignment
  • The stack’s flexibility.

    Declaration

    Swift

    open let flexibility: Flexibility?
  • Undocumented

    Declaration

    Swift

    open class StackView: UIView
  • Undocumented

    Declaration

    Swift

    open class StackView: UIView
  • Adds a subview to the stack.

    Subviews MUST implement sizeThatFits so StackView can allocate space correctly. If a subview uses Auto Layout, then the subview can implement sizeThatFits by calling systemLayoutSizeFittingSize.

    Declaration

    Swift

    open func addArrangedSubviews(_ subviews: [UIView])
  • Deletes all subviews from the stack.

    Declaration

    Swift

    open func removeArrangedSubviews()
  • Undocumented

    Declaration

    Swift

    open class StackView: UIView
  • Undocumented

    Declaration

    Swift

    open class StackView: UIView
  • Undocumented

    Declaration

    Swift

    open class StackView: UIView