ASStackLayoutSpec Class Reference

Inherits from ASLayoutSpec : NSObject
Declared in ASStackLayoutSpec.h

Overview

A simple layout spec that stacks a list of children vertically or horizontally.

  • All children are initially laid out with the an infinite available size in the stacking direction.
  • In the other direction, this spec’s constraint is passed.
  • The children’s sizes are summed in the stacking direction.
    • If this sum is less than this spec’s minimum size in stacking direction, children with flexGrow are flexed.
    • If it is greater than this spec’s maximum size in the stacking direction, children with flexShrink are flexed.
    • If, even after flexing, the sum is still greater than this spec’s maximum size in the stacking direction, justifyContent determines how children are laid out.

For example:

  • Suppose stacking direction is Vertical, min-width=100, max-width=300, min-height=200, max-height=500.
  • All children are laid out with min-width=100, max-width=300, min-height=0, max-height=INFINITY.
  • If the sum of the childrens' heights is less than 200, children with flexGrow are flexed larger.
  • If the sum of the childrens' heights is greater than 500, children with flexShrink are flexed smaller. Each child is shrunk by ((sum of heights) - 500)/(number of flexShrink-able children).
  • If the sum of the childrens' heights is greater than 500 even after flexShrink-able children are flexed, justifyContent determines how children are laid out.

+ newWithStyle:children:

Specifies how children are laid out.

+ (instancetype)newWithStyle:(ASStackLayoutSpecStyle)style children:(NSArray *)children

Parameters

style

Specifies how children are laid out.

children

ASLayoutable children to be positioned.

Declared In

ASStackLayoutSpec.h